/* SYON R-9 — first visual prototype */

:root {
  --lcd: #d8d8d0;
  --lcd-deep: #c7c7bf;
  --ink: #252823;
  --muted: #62665d;
  --line: #8d9086;
  --shell: #b5b6ae;
  --shell-dark: #85877f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  padding: 24px;
  background: #d0d0c8;
  color: var(--ink);
  font-family: Verdana, Arial, sans-serif;
}

button { font: inherit; }

.r9-device {
  width: 100%;
  max-width: 1080px;
  height: calc(100vh - 48px);
  max-height: 720px;
  min-height: 430px;
  margin: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px;
  overflow: hidden;
  background: var(--shell);
  border: 1px solid var(--shell-dark);
  box-shadow: 0 2px 0 rgba(255,255,255,.45) inset,
              0 -2px 0 rgba(0,0,0,.08) inset,
              12px 14px 0 rgba(55,57,52,.18);
}

.display {
  min-width: 0;
  min-height: 0;
  padding: 14px;
  background: var(--shell);
}

.display-header {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px 8px;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: .08em;
  border-bottom: 1px solid var(--line);
}

.system-name { font-weight: bold; }

.clock {
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.clock-colon {
  animation: clock-blink 1s steps(1, end) infinite;
}

.screen-content {
  height: calc(100% - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 28px 32px;
  background: var(--lcd);
  border: 1px solid var(--line);
  border-top: 0;
}

.home-screen {
  max-width: 680px;
  margin: 7vh auto 0;
}

.welcome-mark {
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .16em;
}

.home-screen h1 {
  margin: 0;
  max-width: 520px;
  font-size: 1.5rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: normal;
  line-height: 1.2;
}

.device-code {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
}

.home-status {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding: 7px 9px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: .06em;
}

.app {
  max-width: 760px;
  margin: 0 auto;
}

.app-heading {
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: bold;
  letter-spacing: .1em;
}

.mail-list { display: grid; gap: 1px; }

.mail-item {
  width: 100%;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 0 12px;
  padding: 10px 9px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
}

.mail-item:hover,
.mail-item:focus-visible {
  background: var(--lcd-deep);
  border-color: var(--line);
  outline: none;
}

.mail-date {
  grid-row: 1 / span 2;
  color: var(--muted);
  font-size: 10px;
}

.mail-sender {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: bold;
}

.mail-subject {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.message-view { padding-bottom: 40px; }

.back-button {
  padding: 3px 0;
  margin-bottom: 20px;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: .05em;
}

.back-button:hover { color: var(--ink); }

.message-meta {
  padding-bottom: 17px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.7;
}

.indent { padding-left: 20px; }

.message-body {
  max-width: 650px;
  font-size: 14px;
  line-height: 1.75;
}

.message-body p { margin: 0 0 1.25em; }

.placeholder {
  max-width: 600px;
}

.placeholder p {
  color: var(--muted);
  font-size: 12px;
}

.quick-access {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 7px;
  background: var(--shell);
  border-left: 1px solid var(--shell-dark);
}

.rail-brand {
  padding: 0 5px 13px;
  margin-bottom: 5px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .08em;
  text-align: center;
}

.nav-button {
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 5px 2px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 8px;
  letter-spacing: .05em;
}

.nav-button:hover {
  color: var(--ink);
  background: rgba(255,255,255,.16);
}

.nav-button.active {
  color: var(--ink);
  background: var(--lcd);
  border-color: var(--line);
  box-shadow: 1px 1px 0 rgba(0,0,0,.12);
}

.nav-icon {
  font-size: 17px;
  line-height: 1;
}

.rail-status {
  margin-top: auto;
  padding: 9px 3px 2px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
  font-size: 8px;
  line-height: 1.7;
  letter-spacing: .06em;
}

.battery-placeholder {
  display: block;
  color: var(--ink);
  letter-spacing: -1px;
}

.hidden { display: none !important; }

@keyframes clock-blink {
  0% { opacity: 1; }
  49% { opacity: 1; }
  50% { opacity: 0; }
  100% { opacity: 0; }
}

/* Modos de Pantalla Responsiva */

@media (max-width: 700px) {
  body { padding: 10px; }

  .r9-device {
    height: calc(100vh - 20px);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) 82px;
  }

  .display { padding: 8px; }
  .screen-content { padding: 20px 16px 28px; }
  .quick-access { padding-left: 4px; padding-right: 4px; }

  .nav-button {
    min-height: 48px;
    font-size: 7px;
  }

  .nav-icon { font-size: 15px; }
}

@media (max-aspect-ratio: 1/1) {
  .r9-device {
    width: 100%;
    height: calc(100vh - 20px);
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .home-screen { margin-top: 5vh; }
  .message-body { font-size: 13px; }
}

/* Reorientación automática a Portrait (ej. 9:16) */
@media (orientation: portrait) {
  body { padding: 0; }

  .r9-device {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: none;
    box-shadow: none;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .quick-access {
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 6px 8px;
    border-left: none;
    border-top: 1px solid var(--shell-dark);
  }

  .rail-brand,
  .rail-status {
    display: none;
  }

  .nav-button {
    min-height: 46px;
    padding: 4px 6px;
  }
}

/* Modo Pantalla Completa / Maximizado */
@media (min-width: 1200px) and (min-height: 700px) {
  body {
    padding: 0;
  }

  .r9-device {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    border: none;
    box-shadow: none;
  }
}