:root {
  --bg: #000;
  --tile: #111114;
  --line: #1f1f25;
  --text: #ececef;
  --muted: #8b8b95;
  --accent: #d97757;
  --green: #1ed760;
  --warn: #f2b84b;
  --red: #ff5a5f;
  --blue: #7aa7ff;
  --deep: #4b5bd6;
  --core: #6f8cff;
  --rem: #b07cff;
  --awake: #f2b84b;
  --r: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
#shift { transition: transform 2s ease; min-height: 100%; }
#grid {
  display: grid;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 10px) calc(env(safe-area-inset-bottom) + 10px) calc(env(safe-area-inset-left) + 10px);
  grid-template-columns: 1fr;
}
.tile { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.tile header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
h2 { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.spark { color: var(--accent); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); font-size: 14px; list-style: none; }
button { font: inherit; color: inherit; background: #1c1c22; border: 0; border-radius: 12px; padding: 10px 14px; }
button:active { transform: scale(.96); opacity: .85; }
button.ghost { background: transparent; color: var(--muted); }
button.small { padding: 4px 8px; font-size: 12px; }
.pill { border-radius: 999px; padding: 10px 18px; background: var(--accent); color: #000; font-weight: 600; }
.pill.ghost { background: #1c1c22; color: var(--text); }

/* Reloj */
.tile-clock { background: transparent; border: 0; padding: 6px 6px 2px; }
.clock { font-size: 76px; font-weight: 200; letter-spacing: -2px; line-height: 1; font-variant-numeric: tabular-nums; }
.ss { font-size: 22px; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.date { font-size: 18px; color: var(--text); margin-top: 6px; }
.status { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; }
.dot.off { background: var(--red); }

/* Claude */
.feed { list-style: none; margin: 0; padding: 0; }
.feed > li { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); animation: in .35s ease; }
.feed > li:first-child { border-top: 0; }
.feed .ic { width: 22px; flex: none; text-align: center; font-size: 15px; line-height: 20px; }
.feed .bd { flex: 1; min-width: 0; }
.feed .tt { font-size: 15px; font-weight: 600; line-height: 20px; }
.feed .mm { font-size: 13px; color: #c2c2c9; margin-top: 2px; word-wrap: break-word; }
.feed .md { font-size: 13px; color: #d6d6dc; margin-top: 4px; line-height: 1.45; }
.feed .md code { background: #000; padding: 1px 5px; border-radius: 5px; font-size: 12px; }
.feed .md ul { margin: 4px 0; padding-left: 18px; }
.feed .md li { margin: 2px 0; }
.feed .at { font-size: 11px; color: var(--muted); flex: none; }
.feed > li.success .ic { color: var(--green); }
.feed > li.warn .ic { color: var(--warn); }
.feed > li.error .ic { color: var(--red); }
.feed > li.card { background: #16161b; border-radius: 12px; padding: 10px; border: 0; margin: 4px 0; }
.pending-strip { background: var(--accent); color: #000; border-radius: 12px; padding: 10px 12px; font-weight: 600; margin-bottom: 8px; }
@keyframes in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Música */
.music { display: flex; gap: 12px; align-items: center; }
.art { width: 72px; height: 72px; border-radius: 10px; background: #1c1c22 center/cover no-repeat; flex: none; }
.meta { min-width: 0; }
.track { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.artist { font-size: 14px; color: #c2c2c9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device { font-size: 12px; color: var(--green); margin-top: 3px; }
.progress { height: 4px; background: #24242b; border-radius: 2px; margin: 12px 0 8px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: var(--text); transition: width 1s linear; }
.controls { display: flex; justify-content: center; align-items: center; gap: 22px; }
.controls button { width: 56px; height: 56px; border-radius: 50%; font-size: 22px; background: #1c1c22; }
.controls button.big { width: 68px; height: 68px; background: var(--text); color: #000; font-size: 26px; }
input[type=range] { width: 100%; margin-top: 12px; -webkit-appearance: none; appearance: none; height: 4px; background: #24242b; border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--text); }

/* Calendario */
.cal { list-style: none; margin: 0; padding: 0; }
.cal .day { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 10px 0 4px; }
.cal .day:first-child { margin-top: 0; }
.cal .ev { display: flex; gap: 10px; padding: 6px 0; align-items: baseline; }
.cal .ev .time { width: 50px; flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cal .ev .ti { font-size: 15px; }
.cal .ev .loc { font-size: 12px; color: var(--muted); }
.cal .ev.now { border-left: 3px solid var(--accent); padding-left: 8px; margin-left: -11px; }
.cal .ev.now .time { color: var(--accent); }
.cal .ev.past { opacity: .4; }

/* Sueño */
.sleep .total { font-size: 28px; font-weight: 300; }
.sleep .range { font-size: 13px; color: var(--muted); margin-left: 6px; }
.sleep .bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; margin: 10px 0 6px; background: #24242b; }
.sleep .legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: #c2c2c9; }
.sleep .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.week { display: flex; gap: 4px; align-items: flex-end; height: 34px; margin-top: 10px; }
.week div { flex: 1; background: #2b2b35; border-radius: 3px 3px 0 0; min-height: 2px; }
.week div.last { background: var(--core); }

.tile-settings { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; background: transparent; border: 0; padding: 4px 6px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center; z-index: 10; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.sheet { width: 100%; max-width: 560px; background: #16161b; border-radius: 24px 24px 0 0; padding: 22px 20px calc(env(safe-area-inset-bottom) + 18px); animation: up .3s ease; max-height: 92vh; overflow-y: auto; }
@media (orientation: landscape) { .modal { align-items: center; } .sheet { border-radius: 24px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-kind { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent); font-weight: 600; }
.sheet h3 { font-size: 22px; margin: 6px 0 10px; }
.sheet pre { white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 14px; background: #000; padding: 12px; border-radius: 12px; margin: 0; max-height: 34vh; overflow-y: auto; }
.sheet pre:empty { display: none; }
.sheet-detail { color: var(--muted); font-size: 13px; margin-top: 8px; }
.countdown { height: 3px; background: #24242b; border-radius: 2px; margin: 14px 0; overflow: hidden; }
#mCountdown { height: 100%; background: var(--accent); width: 100%; }
.sheet-buttons { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.sheet-buttons button { padding: 16px; font-size: 17px; font-weight: 600; border-radius: 14px; }
.sheet-buttons button.primary { background: var(--green); color: #000; }
.sheet-buttons button.danger { background: #2a1416; color: var(--red); }
.sheet-buttons button.wide { grid-column: 1 / -1; }
.sheet-more { text-align: center; color: var(--muted); font-size: 12px; margin-top: 10px; }
.device-list { list-style: none; padding: 0; margin: 0 0 14px; }
.device-list li { padding: 14px 4px; border-top: 1px solid var(--line); font-size: 16px; }
.device-list li.active { color: var(--green); }

.night { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity 3s; z-index: 5; }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px); transform: translateX(-50%); background: #24242b; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 20; max-width: 90%; }

/* Horizontal (soporte en el escritorio) */
@media (orientation: landscape) {
  #grid {
    grid-template-columns: 1fr 1.1fr 1fr;
    grid-template-rows: auto 1fr auto auto;
    grid-template-areas: "clock claude cal" "music claude cal" "music claude sleep" "settings claude sleep";
    height: 100vh; height: 100dvh;
  }
  .tile-clock { grid-area: clock; } .tile-claude { grid-area: claude; } .tile-cal { grid-area: cal; }
  .tile-music { grid-area: music; } .tile-sleep { grid-area: sleep; } .tile-settings { grid-area: settings; }
  .tile-claude, .tile-cal { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
  .feed, .cal { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .tile-clock { padding: 0 4px; } .clock { font-size: 46px; } .ss { font-size: 16px; } .date { font-size: 14px; margin-top: 0; } .status { margin-top: 2px; }
  .tile { padding: 10px 12px; }
  .art { width: 44px; height: 44px; } .tile-music header { margin-bottom: 4px; } .track { font-size: 15px; } .artist { font-size: 13px; }
  .progress { margin: 8px 0 6px; }
  .controls button { width: 44px; height: 44px; font-size: 18px; } .controls button.big { width: 52px; height: 52px; font-size: 20px; }
  input[type=range] { margin-top: 8px; }
  .sleep .total { font-size: 22px; } .week { display: none; }
  .tile-settings { padding: 0 4px; } .tile-settings #hint { display: none; }
  .tile-music { overflow: hidden; } .tile-settings .pill { padding: 7px 14px; font-size: 14px; }
}
