:root {
  --bg: #03080C;
  --ink: #E8FBFF;
  --ink-2: #DFF7FC;
  --muted: #8FC3D1;
  --dim: #6F8C96;
  --cyan: #4FD8F0;
  --amber: #FFB547;
  --amber-ink: #FBE7C6;
  --amber-muted: #E8C48A;
  --line: rgba(79, 216, 240, 0.3);
  --display: 'Rajdhani', 'Noto Sans KR', sans-serif;
  --body: 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink-2); font-family: var(--body); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior: none; }
button { font-family: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.app {
  position: relative; height: 100%; overflow: hidden;
  background-image:
    radial-gradient(circle at 50% 20%, rgba(79, 216, 240, 0.12), transparent 50%),
    linear-gradient(rgba(79, 216, 240, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(79, 216, 240, 0.035) 1px, transparent 1px);
  background-size: 100% 100%, 26px 26px, 26px 26px;
}

.content { position: relative; height: 100%; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 14px) 0 calc(var(--safe-b) + 112px); }

/* 상단 바 */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 0 18px 6px; font-family: var(--display); font-size: 13px; font-weight: 600; letter-spacing: 2px; color: var(--muted); }
.brand { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#clock { white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { letter-spacing: 1px; font-size: 12px; padding: 0 10px 6px 16px; }
  .brand .mode { display: none; }
}
.diamond { width: 8px; height: 8px; background: var(--cyan); transform: rotate(45deg); box-shadow: 0 0 8px var(--cyan); }
.mode { font-size: 11px; letter-spacing: 1.5px; padding: 3px 9px; border: 1px solid var(--line); border-radius: 999px; }
.mode.live { color: var(--cyan); border-color: var(--cyan); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 50%; }
.icon-btn.ring { width: 36px; height: 36px; border: 1px solid rgba(143, 195, 209, 0.4); color: var(--ink-2); }

.eyebrow { margin: 0; font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: 3px; color: var(--muted); }
.eyebrow.warm { color: var(--amber-muted); }

/* 레이아웃 */
.layout { display: flex; flex-direction: column; gap: 14px; }
.panels { display: flex; flex-direction: column; gap: 14px; padding: 0 16px; }

/* 궤도 계기판 */
.orbit { position: relative; width: 100%; max-width: 480px; margin: 0 auto; aspect-ratio: 400 / 330; }
.orbit-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.spin { transform-origin: 200px 165px; animation: spin 28s linear infinite; }
.spin-r { transform-origin: 200px 165px; animation: spin 46s linear infinite reverse; }
.sweep { transform-origin: 200px 165px; animation: spin 6s linear infinite; }
.arc { transition: stroke-dasharray 1s cubic-bezier(.2, .8, .2, 1); }
.flow { animation: flow 1.2s linear infinite; }
.core { position: absolute; left: 50%; top: 50%; width: 34%; aspect-ratio: 1; transform: translate(-50%, -50%); display: flex; align-items: center; justify-content: center; }
.breath { display: flex; flex-direction: column; align-items: center; gap: 1px; animation: breath 4.5s ease-in-out infinite; }
.core .label { font-family: var(--display); font-size: 11px; letter-spacing: 3px; color: var(--muted); }
.core .temp { font-family: var(--display); font-size: clamp(36px, 11vw, 64px); font-weight: 600; line-height: 1; color: var(--ink); text-shadow: 0 0 14px rgba(79, 216, 240, 0.55); }
.core-sub { font-size: 12px; color: var(--muted); }

.node {
  position: absolute; transform: translate(-50%, -50%); width: 24%; min-width: 92px; max-width: 150px; min-height: 52px;
  padding: 7px 10px; border-radius: 14px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px;
  text-align: left; cursor: pointer; border: 1px solid rgba(143, 195, 209, 0.32); background: rgba(3, 8, 12, 0.88);
  animation: pop .7s cubic-bezier(.2, .9, .25, 1.2) both, float 5s ease-in-out infinite;
  transition: background-color .45s, border-color .45s, box-shadow .45s;
}
.node .n-head { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.node .dot { width: 7px; height: 7px; border-radius: 50%; background: #4A6470; transition: background-color .45s; }
.node .n-sub { font-family: var(--display); font-size: 12px; font-weight: 600; letter-spacing: .5px; color: var(--muted); }
.node.on { border-color: var(--cyan); background: rgba(79, 216, 240, 0.16); box-shadow: 0 0 14px rgba(79, 216, 240, 0.28); }
.node.on .dot { background: var(--cyan); }
.node.on .n-sub { color: var(--cyan); }
.node.action { border-color: var(--amber); background: rgba(255, 181, 71, 0.1); }
.node.action .dot { background: var(--amber); }
.node.action .n-sub { color: var(--amber); }
.node.off-line { opacity: .5; }
.node:active { transform: translate(-50%, -50%) scale(.95); }

/* 패널 */
.panel { padding: 14px; border: 1px solid var(--line); background: rgba(79, 216, 240, 0.04); clip-path: polygon(16px 0, 100% 0, 100% calc(100% - 16px), calc(100% - 16px) 100%, 0 100%, 0 16px); display: flex; flex-direction: column; gap: 10px; }
.panel-plain { display: flex; flex-direction: column; gap: 8px; }
.holo-l { animation: holoL .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0ms); }
.holo-r { animation: holoR .9s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--d, 0ms); }

.vehicle { border-color: rgba(255, 181, 71, 0.5); background: rgba(255, 181, 71, 0.05); }
.vehicle-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.car { width: 150px; height: auto; }
#carBody.idle-bounce { animation: bounce .45s ease-in-out infinite; }
#door { transform-box: fill-box; transform-origin: 100% 50%; transition: transform .8s cubic-bezier(.34, 1.56, .64, 1); }
#door.open { transform: translateX(4px) scaleX(.42) skewY(-7deg); }
#doorGlow, #headlight, #carGlow { transition: fill-opacity .5s ease; }
#carGlow.on { animation: pulse 2.6s ease-in-out infinite; }
.car-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.car-btn { min-height: 52px; padding: 6px 10px; font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: 2.5px; border: 1px solid rgba(255, 181, 71, 0.5); background: transparent; color: var(--amber-ink); cursor: pointer; }
#btnEngine { border-color: var(--amber); background: rgba(255, 181, 71, 0.12); }
#btnEngine[aria-pressed="true"] { background: var(--amber); color: var(--bg); box-shadow: 0 0 18px rgba(255, 181, 71, 0.45); }
#btnDoor[aria-pressed="true"] { border-color: var(--cyan); background: rgba(79, 216, 240, 0.16); color: var(--cyan); }

.hud-btn { transition: background-color .45s ease, border-color .45s ease, color .45s ease, box-shadow .45s ease, transform .18s ease; }
.hud-btn:active { transform: scale(.95); }

/* 할 일 / 메모 */
.notes-panel { clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px)); }
.tabs-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; }
.tab { min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-family: var(--display); font-size: 13px; font-weight: 700; letter-spacing: 1px; cursor: pointer; transition: background-color .35s, color .35s; }
.tab[aria-selected="true"] { background: var(--cyan); color: var(--bg); }
.today { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.today li button, .today li .row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 44px; border: 0; background: transparent; text-align: left; padding: 0; cursor: pointer; font-size: 15px; color: var(--ink); }
.today .tag { flex: 0 0 auto; min-width: 54px; font-family: var(--display); font-size: 13px; font-weight: 700; letter-spacing: 1px; color: var(--cyan); }
.today .tag.todo { color: var(--amber); }
.today .done .tag { color: var(--dim); }
.today .done .txt { color: var(--muted); text-decoration: line-through; }
.today .empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.pad-tools { display: flex; align-items: center; gap: 6px; }
.pen { width: 32px; height: 32px; border-radius: 50%; padding: 0; background: var(--c); border: 3px solid transparent; cursor: pointer; }
.pen[aria-pressed="true"] { border-color: var(--bg); box-shadow: 0 0 0 2px var(--c); }
.pad { position: relative; height: 260px; border-radius: 14px; border: 1px dashed rgba(79, 216, 240, 0.35); background-color: rgba(3, 8, 12, 0.6); background-image: repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(79, 216, 240, 0.1) 31px, rgba(79, 216, 240, 0.1) 32px); overflow: hidden; }
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 15px; pointer-events: none; text-align: center; padding: 0 16px; }

.pill-btn { min-height: 36px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--cyan); color: var(--bg); font-size: 14px; font-weight: 700; cursor: pointer; }
.pill-btn.ghost { background: transparent; border: 1px solid rgba(143, 195, 209, 0.45); color: var(--ink-2); font-weight: 500; }
.pill-btn.warm { background: var(--amber); }

/* 루틴 */
.segment { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border: 1px solid rgba(79, 216, 240, 0.35); border-radius: 28px; }
.segment button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 999px; background: transparent; color: var(--ink); font-size: 15px; font-weight: 700; cursor: pointer; }
.segment button[aria-pressed="true"] { background: var(--cyan); color: var(--bg); box-shadow: 0 0 16px rgba(79, 216, 240, 0.45); }
.segment button.custom { color: var(--amber-ink); }

/* 떠 있는 비서 바 */
.pill-wrap { position: absolute; left: 14px; right: 14px; bottom: calc(var(--safe-b) + 18px); z-index: 3; display: flex; justify-content: center; animation: dock .9s cubic-bezier(.2, .8, .2, 1) .5s both; }
.pill { width: 100%; max-width: 560px; display: flex; align-items: center; border-radius: 999px; border: 1px solid rgba(79, 216, 240, 0.4); background: rgba(8, 20, 28, 0.92); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); box-shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 0 18px rgba(79, 216, 240, .18); transition: opacity .35s ease, transform .45s cubic-bezier(.2, .8, .2, 1); }
.app.dock-open .pill { opacity: 0; transform: translateY(16px) scale(.96); pointer-events: none; }
.pill-main { flex: 1 1 auto; min-width: 0; min-height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 6px 0 16px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.orb { flex: 0 0 auto; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; border: 1.5px solid var(--cyan); display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 14px; font-weight: 700; color: var(--cyan); }
.pill-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pill-line { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill-badge { font-size: 12px; font-weight: 700; color: var(--amber); }
.mic-sm { flex: 0 0 auto; width: 52px; height: 52px; margin-right: 6px; border-radius: 50%; border: 1px solid var(--cyan); background: rgba(79, 216, 240, .14); color: var(--cyan); display: flex; align-items: center; justify-content: center; cursor: pointer; }

.backdrop { position: absolute; inset: 0; z-index: 4; border: 0; padding: 0; background: rgba(0, 0, 0, .55); opacity: 0; pointer-events: none; transition: opacity .4s ease; }
.app.dock-open .backdrop { opacity: 1; pointer-events: auto; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; height: min(72%, 560px); margin: 0 auto; max-width: 640px;
  border-top: 1px solid rgba(79, 216, 240, .35); border-radius: 28px 28px 0 0; background: rgba(6, 15, 21, .98);
  padding: 10px 16px calc(var(--safe-b) + 18px); display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 -20px 50px rgba(0, 0, 0, .6); transform: translateY(105%); transition: transform .55s cubic-bezier(.2, .8, .2, 1);
}
.app.dock-open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: 90%; align-self: flex-start; padding: 9px 13px; border-radius: 4px 16px 16px 16px; border: 1px solid rgba(79, 216, 240, .22); background: rgba(79, 216, 240, .04); animation: msg .5s cubic-bezier(.2, .8, .2, 1) both; }
.msg .who { font-family: var(--display); font-size: 11px; font-weight: 700; letter-spacing: 1.5px; color: var(--cyan); }
.msg p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink); }
.msg.me { align-self: flex-end; border-radius: 16px 16px 4px 16px; border-color: rgba(79, 216, 240, .5); background: rgba(79, 216, 240, .14); }
.msg.me .who { color: #9BEBFA; }
.msg.suggest { border-color: var(--amber); background: rgba(255, 181, 71, .07); }
.msg.suggest .who { color: var(--amber); }
.msg .acts { display: flex; gap: 6px; margin-top: 4px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips button { flex: 0 0 auto; min-height: 38px; padding: 0 14px; border: 1px solid rgba(79, 216, 240, .45); border-radius: 999px; background: rgba(79, 216, 240, .06); color: var(--ink); font-size: 13px; cursor: pointer; white-space: nowrap; }
.ask { display: flex; align-items: center; gap: 10px; }
.ask input { flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(79, 216, 240, .4); background: rgba(3, 8, 12, .8); color: var(--ink); font-size: 16px; font-family: var(--body); }
.ask input::placeholder { color: var(--dim); }
.mic { position: relative; flex: 0 0 auto; width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--cyan); background: rgba(79, 216, 240, .12); color: var(--cyan); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 0 18px rgba(79, 216, 240, .4); }
.mic[aria-pressed="true"] { background: var(--cyan); color: var(--bg); }
.mic-ring { position: absolute; inset: -1px; border-radius: 50%; border: 2px solid var(--cyan); opacity: 0; }
.mic[aria-pressed="true"] .mic-ring { animation: ring 1.6s ease-out infinite; }

/* 설정 */
.settings { width: min(560px, calc(100% - 24px)); max-height: 86vh; border: 1px solid var(--line); border-radius: 22px; background: #071219; color: var(--ink-2); padding: 20px; }
.settings::backdrop { background: rgba(0, 0, 0, .6); }
.settings h2 { margin: 0 0 12px; font-size: 20px; }
.settings form { display: flex; flex-direction: column; gap: 12px; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.settings input[type=text], .settings input:not([type]), .settings input[type=password] { height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid rgba(79, 216, 240, .35); background: rgba(3, 8, 12, .8); color: var(--ink); font-size: 16px; font-family: var(--body); }
.settings fieldset { border: 1px solid rgba(79, 216, 240, .2); border-radius: 12px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.settings legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.settings .radio { flex-direction: row; align-items: center; gap: 8px; min-height: 40px; color: var(--ink-2); }
.settings details { border: 1px solid rgba(79, 216, 240, .2); border-radius: 12px; padding: 10px 12px; }
.settings summary { cursor: pointer; min-height: 28px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.settings-note { margin: 0; min-height: 20px; font-size: 13px; color: var(--amber); }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.scan { position: absolute; left: 0; right: 0; height: 80px; z-index: 1; pointer-events: none; background: linear-gradient(180deg, transparent, rgba(79, 216, 240, .07), transparent); animation: scan 7s linear infinite; }
.pulse { animation: pulse 2.6s ease-in-out infinite; }
.pop { animation: popc .7s cubic-bezier(.2, .9, .25, 1.2) both; }

/* 아이패드: 대화 콘솔을 계기판 아래에 고정 배치 */
.sheet.inline {
  position: relative; left: auto; right: auto; bottom: auto; z-index: 1; width: auto; max-width: none; height: 380px; margin: 4px 28px 0;
  transform: none; transition: none; border: 1px solid rgba(79, 216, 240, .35); border-radius: 24px; box-shadow: none;
  background: rgba(6, 15, 21, .9); padding: 12px 16px 16px; animation: holoR .9s cubic-bezier(.2, .8, .2, 1) .3s both;
}
.sheet.inline #sheetClose { display: none; }
.app.tablet .pill-wrap, .app.tablet .backdrop { display: none; }

/* 아이패드 공통 (세로 744px~) */
@media (min-width: 700px) {
  .content { padding-bottom: calc(var(--safe-b) + 32px); }
  .topbar { padding: 6px 32px 10px; font-size: 14px; }
  .node { min-height: 72px; padding: 10px 14px; border-radius: 18px; }
  .node .n-head { font-size: 16px; }
  .node .n-sub { font-size: 14px; }
  .core .label { font-size: 13px; }
  .core-sub { font-size: 14px; }
  .car { width: 210px; }
  .pad { height: 340px; }
  .sheet { right: 28px; left: auto; width: 560px; }
}

/* 아이패드 세로: 계기판을 위에 크게, 아래 패널은 두 칸 */
@media (min-width: 700px) and (max-width: 1099px) {
  .orbit { max-width: 620px; }
  .panels {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 0 28px;
    grid-template-areas: "car notes" "routines notes";
    align-items: start;
  }
  .vehicle { grid-area: car; }
  .notes-panel { grid-area: notes; }
  .panels > .panel-plain { grid-area: routines; }
  .segment { grid-template-columns: repeat(2, minmax(0, 1fr)); border-radius: 22px; }
  .car-btns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 아이패드 가로: 왼쪽 계기판, 오른쪽 패널 */
@media (min-width: 1100px) {
  .layout { flex-direction: row; align-items: flex-start; gap: 24px; padding: 0 28px; }
  .left-col { flex: 0 0 52%; max-width: 640px; position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; }
  .orbit { max-width: none; margin: 0; }
  .sheet.inline { margin: 0; height: 330px; }
  .panels { flex: 1 1 auto; padding: 0; min-width: 0; }
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes popc { from { opacity: 0; transform: translate(-50%, -50%) scale(.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -5px; } }
@keyframes flow { to { stroke-dashoffset: -20; } }
@keyframes breath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes scan { 0% { top: -80px; } 100% { top: 100%; } }
@keyframes holoL { from { opacity: 0; transform: perspective(900px) rotateY(16deg) translateX(-36px); } to { opacity: 1; transform: perspective(900px) rotateY(3deg); } }
@keyframes holoR { from { opacity: 0; transform: perspective(900px) rotateY(-16deg) translateX(36px); } to { opacity: 1; transform: perspective(900px) rotateY(-3deg); } }
@keyframes msg { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes ring { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes dock { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1.6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
