* { box-sizing: border-box; }
:root {
  --ink: #161a22; --ink-2: #5a6170; --ink-3: #8a909c; --line: #e5e7ec; --bg: #ffffff; --bg-2: #f3f4f7;
  --accent: #3d6fd8; --danger: #c2412d; --me: #2f5fd0;
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  color: var(--ink); background: #0d1016;
}
body { margin: 0; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 0%, #1d2330, #0d1016 70%); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #7aa2ff; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }

/* ── 휴대폰 프레임 ── */
.phone { position: relative; width: min(390px, 100%); height: min(820px, calc(100dvh - 40px)); min-height: 520px;
  display: flex; flex-direction: column; background: var(--bg); border: 8px solid #262b36;
  border-radius: 46px; overflow: hidden; box-shadow: 0 30px 90px #0009, inset 0 0 0 1px #000; font-size: 15px; }
.phone.text-large { font-size: 17.5px; }
.status { display: flex; justify-content: space-between; align-items: center; padding: 14px 26px 8px; font-size: 14px; font-weight: 600;
  font-variant-numeric: tabular-nums; position: relative; z-index: 2; }
.status-icons { display: flex; align-items: flex-end; gap: 2px; }
.status-icons i { width: 3px; background: currentColor; border-radius: 1px; }
.status-icons i:nth-child(1) { height: 5px; } .status-icons i:nth-child(2) { height: 7px; } .status-icons i:nth-child(3) { height: 9px; }
.status-icons b { width: 20px; height: 10px; border: 1.5px solid currentColor; border-radius: 3px; margin-left: 6px; position: relative; }
.status-icons b::after { content: ""; position: absolute; inset: 1.5px; right: 5px; background: currentColor; border-radius: 1px; }
#screen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#storage-status { margin: 0; padding: 8px 16px; font-size: 12px; color: var(--danger); background: #fff4f2; }
footer { padding: 4px 0 6px; display: flex; justify-content: center; position: relative; z-index: 2; }
#home { display: grid; place-items: center; width: 160px; height: 24px; background: none; border: 0; }
#home span { height: 5px; width: 124px; background: currentColor; border-radius: 20px; opacity: .85; }

.phone[data-theme="lock"], .phone[data-theme="intro"] { color: #fff; background: #0f1320; }
.phone[data-theme="lock"] #screen, .phone[data-theme="intro"] #screen { color: #fff; }
.phone[data-theme="lock"]::before, .phone[data-theme="intro"]::before { content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 70% at 20% 0%, #33415f 0%, transparent 60%),
              radial-gradient(90% 60% at 100% 100%, #3a2c45 0%, transparent 60%), #10131d; }
.phone[data-theme="home"] { background: linear-gradient(170deg, #dfe3ea 0%, #c9d0dc 55%, #b9c1cf 100%); }
.phone[data-theme="lock"] > :not(.banner), .phone[data-theme="intro"] > :not(.banner) { position: relative; }

/* ── 홈 ── */
.home { flex: 1; padding: 30px 22px; }
.app-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 8px; }
.app-icon { border: 0; padding: 0; background: none; font-size: .78em; display: grid; justify-items: center; gap: 7px; color: var(--ink); }
.app-icon b { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 15px; color: #fff; position: relative;
  box-shadow: 0 2px 6px #0002; }
.app-icon svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.badge { position: absolute; top: -6px; right: -6px; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: #e5483a;
  color: #fff; font: 600 12px/21px system-ui, sans-serif; font-style: normal; text-align: center; }

/* ── 전체 화면(시작·잠금) ── */
.full-screen { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.intro { padding: 40px 26px 20px; gap: 22px; }
.intro-brand { margin-top: 18%; }
.intro-co { font-size: .75em; letter-spacing: .18em; opacity: .65; }
.intro h1 { font-size: 2em; letter-spacing: -.01em; margin: 10px 0 6px; }
.intro-sub { opacity: .8; }
.notice { border: 1px solid #ffffff2e; background: #ffffff10; border-radius: 14px; padding: 14px 16px; display: grid; gap: 8px;
  font-size: .85em; line-height: 1.6; }
.notice.light { border-color: var(--line); background: var(--bg-2); color: var(--ink-2); }
.intro .primary { margin-top: auto; }
.primary { border: 0; border-radius: 14px; padding: 15px; background: var(--accent); color: #fff; font-weight: 600; width: 100%; }
.intro .primary { background: #fff; color: #10131d; }
.primary:disabled { opacity: .5; }
.ghost { border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; background: var(--bg); width: 100%; }
.danger { border: 0; border-radius: 12px; padding: 13px; background: #fbe9e6; color: var(--danger); font-weight: 600; width: 100%; }
.form-error { color: #e0675a; font-size: .85em; min-height: 1.2em; }

.register { padding: 26px 22px 20px; background: var(--bg); }
.reg-kicker { color: var(--accent); font-weight: 600; font-size: .85em; }
.register h1 { font-size: 1.6em; margin: 6px 0 4px; }
.reg-sub { color: var(--ink-2); font-size: .9em; margin-bottom: 20px; }
.profile-form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > label, .field legend { font-size: .82em; font-weight: 600; color: var(--ink-2); padding: 0; }
.field input[type="text"], .field input:not([type]), .field select { width: 100%; border: 1px solid var(--line); background: var(--bg-2);
  border-radius: 12px; padding: 12px 13px; font-size: 1em; min-width: 0; }
.seg-row { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-row label { position: relative; }
.seg-row input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-row span { display: block; padding: 9px 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--bg); font-size: .9em; }
.seg-row input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.seg-row input:focus-visible + span { outline: 3px solid #7aa2ff; outline-offset: 2px; }

.lock { padding: 6px 16px 10px; }
.lock-top { text-align: center; margin: 22px 0 26px; }
.lock-day { font-size: .85em; font-weight: 600; letter-spacing: .08em; opacity: .8; }
.lock-time { font-size: 4.6em; font-weight: 300; letter-spacing: -.02em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.lock-notes { display: grid; gap: 8px; }
.note { text-align: left; border: 0; border-radius: 18px; padding: 12px 14px; background: #ffffff26; backdrop-filter: blur(14px);
  display: grid; gap: 2px; color: #fff; }
.note-head { display: flex; justify-content: space-between; font-size: .75em; opacity: .75; }
.note strong { font-size: .92em; }
.note-text { font-size: .9em; opacity: .95; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-more { font-size: .75em; opacity: .7; }
.unlock { margin-top: auto; align-self: center; border: 0; background: #ffffff1f; color: #fff; border-radius: 22px; padding: 10px 22px; font-size: .9em; }

/* ── 앱 공통 ── */
.app-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 12px 10px; border-bottom: 1px solid var(--line); }
.app-head h1 { font-size: 1.05em; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { justify-self: start; background: none; border: 0; padding: 6px 2px; color: var(--accent); font-size: .95em; white-space: nowrap; }
.head-extra { justify-self: end; }
.app-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; }
.pad { padding: 18px 18px 24px; }
.sub { color: var(--ink-3); font-size: .85em; }
.avatar { width: 42px; height: 42px; flex: none; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; font-size: .9em; }
.avatar.big { width: 76px; height: 76px; font-size: 1.6em; }

/* ── 메시지 ── */
.thread-list li + li .thread-row { border-top: 1px solid var(--line); }
.thread-row { width: 100%; display: flex; gap: 12px; align-items: center; padding: 12px 16px; background: none; border: 0; text-align: left; }
.thread-mid { flex: 1; min-width: 0; display: grid; gap: 2px; }
.preview { color: var(--ink-2); font-size: .88em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-side { display: grid; justify-items: end; gap: 4px; }
.time { color: var(--ink-3); font-size: .75em; font-variant-numeric: tabular-nums; }
.count { background: #e5483a; color: #fff; font-size: .72em; font-weight: 600; border-radius: 10px; padding: 1px 7px; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 12px 14px; background: #eef1f6; display: flex; flex-direction: column; gap: 4px; }
.fiction-tag { align-self: center; font-size: .72em; color: var(--ink-3); background: #0000000a; padding: 3px 10px; border-radius: 10px; margin: 4px 0 10px; }
.profile .fiction-tag { margin-top: 18px; }
.msg-row { display: flex; gap: 8px; align-items: flex-start; }
.msg-row.me { justify-content: flex-end; }
.avatar-slot { width: 36px; flex: none; }
.avatar-slot .avatar { width: 36px; height: 36px; font-size: .8em; }
.msg-col { display: grid; gap: 3px; min-width: 0; max-width: 78%; }
.msg-row.me .msg-col { max-width: 80%; }
.sender { font-size: .75em; color: var(--ink-2); }
.bubble-line { display: flex; align-items: flex-end; gap: 6px; }
.msg-row.me .bubble-line { flex-direction: row-reverse; }
.bubble { background: #fff; padding: 9px 12px; border-radius: 4px 16px 16px 16px; line-height: 1.5; overflow-wrap: anywhere; white-space: pre-wrap;
  font-size: .95em; box-shadow: 0 1px 1px #0000000d; min-width: 0; }
.msg-row.me .bubble { background: var(--me); color: #fff; border-radius: 16px 4px 16px 16px; }
.stamp { font-size: .68em; color: var(--ink-3); flex: none; font-variant-numeric: tabular-nums; }
.msg-row + .msg-row:not(.me) .sender { margin-top: 6px; }
.replies { display: grid; gap: 7px; padding: 10px 12px 12px; border-top: 1px solid var(--line); background: var(--bg); }
.reply { text-align: left; border: 1px solid #cdd7ee; background: #f5f8ff; color: #1f3f8f; padding: 11px 13px; border-radius: 14px; line-height: 1.45;
  overflow-wrap: anywhere; }
.reply.picked { background: var(--me); color: #fff; border-color: var(--me); }
.reply:disabled:not(.picked) { opacity: .45; }
.arrive { opacity: 0; animation: arrive .3s ease-out forwards; }
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── 배너 ── */
.banner { position: absolute; top: 46px; left: 10px; right: 10px; z-index: 5; border: 0; text-align: left; display: grid; gap: 2px;
  padding: 11px 14px; border-radius: 16px; background: #fff; color: var(--ink); box-shadow: 0 8px 24px #0003, 0 0 0 1px #0000000f; animation: drop .25s ease-out; }
.banner strong { font-size: .82em; }
.banner span { font-size: .9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes drop { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── 캘린더 ── */
.cal-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; }
.cal-head strong { font-size: 1.35em; }
.cal-head span { color: var(--ink-2); font-size: .9em; font-variant-numeric: tabular-nums; }
.cal-list { display: grid; gap: 10px; }
.cal-item { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 12px; border-radius: 14px; background: var(--bg-2); border-left: 4px solid #c9ced8; }
.cal-item.now { border-left-color: #d0533f; background: #fff6f4; }
.cal-item.done { opacity: .62; }
.cal-time { font-size: .8em; color: var(--ink-2); font-variant-numeric: tabular-nums; padding-top: 2px; }
.cal-info { display: grid; gap: 3px; min-width: 0; }
.cal-place { font-size: .82em; color: var(--ink-2); }
.cal-done { font-size: .75em; color: #3f7d4e; font-weight: 600; }
.cal-actions { display: grid; gap: 6px; margin-top: 8px; }
.cal-btn { text-align: left; border: 1px solid #ecc9c1; background: #fff; border-radius: 10px; padding: 10px 12px; }
.cal-btn.picked { background: #d0533f; color: #fff; border-color: #d0533f; }
.cal-btn:disabled:not(.picked) { opacity: .45; }
.record { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.record h2 { font-size: 1.1em; margin-bottom: 10px; }
.record h3, .profile h3 { font-size: .85em; color: var(--ink-2); margin: 18px 0 8px; }
.record-log { display: grid; gap: 7px; }
.record-log li { display: grid; grid-template-columns: 48px 1fr; gap: 8px; font-size: .9em; line-height: 1.45; }
.stat-grid { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: .92em; }
.stat-grid dt { color: var(--ink-2); }
.stat-grid dd { margin: 0; font-variant-numeric: tabular-nums; text-align: right; }

/* ── 회사 포털 ── */
.portal-co { padding: 14px 18px 8px; font-size: .72em; letter-spacing: .14em; color: var(--ink-3); font-weight: 600; }
.doc-list li + li .doc-row { border-top: 1px solid var(--line); }
.doc-row { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; text-align: left; padding: 14px 18px; background: none; border: 0; }
.doc-row .doc-tag, .doc-row strong, .doc-row .doc-date { grid-column: 1; }
.doc-new { grid-column: 2; grid-row: 1 / 4; align-self: center; background: #e5483a; color: #fff; font-size: .7em; font-weight: 700; border-radius: 50%;
  width: 20px; height: 20px; display: grid; place-items: center; }
.doc-tag { font-size: .72em; color: var(--accent); font-weight: 600; }
.doc-date { font-size: .75em; color: var(--ink-3); }
.doc h2 { font-size: 1.2em; margin: 6px 0 4px; }
.doc-body { margin: 18px 0 0; display: grid; gap: 14px; }
.doc-body dt { font-size: .8em; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }
.doc-body dd { margin: 0; line-height: 1.6; white-space: pre-wrap; }
.doc-actions { margin-top: 26px; }

/* ── 연락처 ── */
.contact-row { width: 100%; display: flex; gap: 12px; align-items: center; padding: 11px 18px; background: none; border: 0; text-align: left; }
.contact-row.mine { padding: 16px 18px; border-bottom: 8px solid var(--bg-2); }
.contact-list li + li .contact-row { border-top: 1px solid var(--line); }
.contact-text { display: grid; gap: 2px; min-width: 0; }
.profile { display: flex; flex-direction: column; align-items: center; text-align: center; }
.profile h2 { font-size: 1.3em; margin-top: 12px; }
.profile .ghost { width: auto; margin-top: 12px; padding: 8px 22px; }
.profile .stat-grid { width: 100%; text-align: left; margin-top: 14px; }
.profile h3 { align-self: flex-start; }
.memories { width: 100%; text-align: left; display: grid; gap: 6px; }
.memories li { background: var(--bg-2); border-radius: 10px; padding: 9px 12px; font-size: .9em; line-height: 1.45; }

/* ── 설정 ── */
.set-list { margin: 14px 14px 0; background: var(--bg-2); border-radius: 14px; overflow: hidden; }
.set-item + .set-item { border-top: 1px solid var(--line); }
.set-row { width: 100%; text-align: left; background: none; border: 0; padding: 14px 16px; }
.set-row::after { content: "›"; float: right; color: var(--ink-3); }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch i { width: 46px; height: 28px; border-radius: 14px; background: #cdd1d9; position: relative; transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px #0003; }
.switch input:checked ~ i { background: #34a35a; }
.switch input:checked ~ i::after { transform: translateX(18px); }
.switch input:focus-visible ~ i { outline: 3px solid #7aa2ff; outline-offset: 2px; }
.set-note { margin: 14px 18px 0; font-size: .8em; color: var(--ink-3); line-height: 1.55; }
.pad .set-note { margin: 12px 0 0; }
.reset { margin: 22px 14px; display: grid; gap: 8px; }
.reset .set-note { margin: 0 4px 4px; color: var(--danger); }
.about h2 { font-size: 1.2em; }
.about .notice { margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  .arrive { animation: none; opacity: 1; }
  .banner { animation: none; }
}
@media (max-width: 480px) {
  body { padding: 0; }
  .phone { width: 100%; height: 100dvh; min-height: 0; border: 0; border-radius: 0; }
  .status { padding-top: max(14px, env(safe-area-inset-top)); }
  footer { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
}
@media (max-width: 340px) {
  .app-icon b { width: 52px; height: 52px; }
  .home { padding: 24px 14px; }
}
