:root {
  color-scheme: light;
  --navy-950: #07172d;
  --navy-900: #0b1f3a;
  --navy-800: #153252;
  --navy-100: #e9eef4;
  --gold-600: #a47a35;
  --gold-100: #f6efe2;
  --ink: #162033;
  --body: #5d6878;
  --muted: #8993a2;
  --line: #dfe4ea;
  --surface: #ffffff;
  --canvas: #f5f7f9;
  --success: #34704a;
  --danger: #a33a3a;
  --warning: #8a641e;
  --shadow: 0 18px 50px rgb(11 31 58 / 8%);
  --radius: 18px;
  --sans: Inter, Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
  --serif: Georgia, "Noto Serif KR", serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  min-height: 100dvh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100dvh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: max(12px, env(safe-area-inset-top)) clamp(18px, 4vw, 42px) 12px;
  border-bottom: 1px solid rgb(223 228 234 / 85%);
  background: rgb(255 255 255 / 94%);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { flex: 0 0 auto; border-radius: 11px; }
.brand span { display: grid; min-width: 0; }
.brand strong {
  color: var(--navy-900);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.2;
}
.brand small {
  overflow: hidden;
  color: var(--gold-600);
  font-size: 10px;
  letter-spacing: .12em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.network-status {
  border-radius: 999px;
  background: #fff3cd;
  color: var(--warning);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.workspace {
  display: flex;
  align-items: stretch;
  min-height: calc(100dvh - 72px);
  width: 100%;
}
.sidebar {
  position: sticky;
  top: 72px;
  flex: 0 0 240px;
  display: flex;
  height: calc(100dvh - 72px);
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.navigation { display: grid; gap: 6px; }
.navigation a {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: 12px;
  color: var(--body);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 650;
}
.navigation a > span:first-child { width: 22px; color: var(--gold-600); font-size: 18px; text-align: center; }
.navigation a:hover { background: var(--canvas); color: var(--navy-900); }
.navigation a.active { background: var(--navy-900); color: white; }
.navigation a.active > span:first-child { color: #e8c98d; }
.sidebar-install {
  border: 1px solid #e4d4b6;
  border-radius: 14px;
  background: var(--gold-100);
  padding: 16px;
}
.sidebar-install strong { color: var(--navy-900); font-family: var(--serif); }
.sidebar-install p { margin: 6px 0 12px; color: var(--body); font-size: 12px; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 38px clamp(20px, 5vw, 64px) 80px;
  outline: none;
}
.loading, .empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}
.page-header { margin-bottom: 24px; }
.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-600);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { color: var(--navy-900); font-family: var(--serif); word-break: keep-all; overflow-wrap: anywhere; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 42px); line-height: 1.15; }
h2 { margin-bottom: 8px; font-size: 22px; }
h3 { margin-bottom: 6px; font-size: 17px; }
.page-header > p:last-child, .card p { color: var(--body); }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(20px, 3vw, 28px);
  box-shadow: 0 1px 0 rgb(11 31 58 / 2%);
}
.card-accent { border-top: 3px solid var(--gold-600); }
.stat { display: flex; min-height: 164px; flex-direction: column; justify-content: space-between; }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stat-value { color: var(--navy-900); font-family: var(--serif); font-size: 34px; }
.summary-text { min-height: 52px; margin: 12px 0 0; white-space: pre-wrap; }
.muted { color: var(--muted) !important; font-size: 13px; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--navy-900);
  border-radius: 10px;
  background: var(--navy-900);
  color: white;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.button:hover { background: var(--navy-800); }
.button:disabled { cursor: wait; opacity: .55; }
.button-outline { background: transparent; color: var(--navy-900); }
.button-ghost { min-height: 36px; border-color: transparent; background: transparent; color: var(--navy-900); padding: 7px 10px; }
.button-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.auth-layout {
  display: grid;
  width: 100%;
  align-items: start;
  grid-template-columns: 1fr;
  gap: 28px;
}
@media (min-width: 1100px) {
  .auth-layout {
    min-height: calc(100dvh - 190px);
    align-items: center;
    grid-template-columns: minmax(280px, 1fr) minmax(360px, 460px);
    gap: clamp(40px, 6vw, 96px);
  }
}
.auth-intro { max-width: 540px; min-width: 0; }
.auth-intro h1 {
  font-size: clamp(28px, 4.2vw, 52px);
  line-height: 1.25;
  word-break: keep-all;
  overflow-wrap: break-word;
}
.auth-points { display: grid; gap: 12px; margin-top: 28px; }
.auth-point { display: flex; gap: 12px; color: var(--body); font-size: 14px; }
.auth-point span { color: var(--gold-600); font-weight: 900; }
.auth-card { box-shadow: var(--shadow); }
.auth-switch { margin: 18px 0 0; color: var(--body); font-size: 13px; text-align: center; }
.auth-switch button { border: 0; background: transparent; color: var(--gold-600); font-weight: 800; text-decoration: underline; }

.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; }
.field-full { grid-column: 1 / -1; }
.field label { color: var(--navy-900); font-size: 12px; font-weight: 750; }
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  padding: 12px 13px;
}
.field textarea { min-height: 130px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold-600);
  outline: 3px solid rgb(164 122 53 / 12%);
}
.form-status { min-height: 20px; margin: 0; font-size: 13px; }
.form-status.error { color: var(--danger); }
.form-status.success { color: var(--success); }

.message-list { display: grid; gap: 10px; }
.message-item {
  display: grid;
  width: 100%;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 18px;
  color: inherit;
  text-align: left;
}
.message-item:hover { border-color: #c3cbd5; transform: translateY(-1px); }
.message-item.unread { border-left: 4px solid var(--gold-600); }
.message-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.message-title { margin: 0; color: var(--navy-900); font-family: var(--serif); font-size: 18px; font-weight: 700; }
.scope { border-radius: 999px; background: var(--navy-100); color: var(--navy-800); padding: 4px 8px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.scope.direct { background: var(--gold-100); color: var(--gold-600); }
.message-body { color: var(--body); white-space: pre-wrap; }
.badge {
  display: inline-grid;
  min-width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 999px;
  background: var(--gold-600);
  color: white;
  padding: 0 5px;
  font-size: 10px;
  line-height: 1;
}

.install-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
  border: 1px solid #e4d4b6;
  border-radius: 14px;
  background: var(--gold-100);
  padding: 16px 18px;
}
.install-card p { margin: 2px 0 0; color: var(--body); font-size: 13px; }
.ios-instructions { margin: 12px 0 0; color: var(--body); font-size: 13px; }

.install-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgb(7 23 45 / 55%);
  padding: 20px;
  backdrop-filter: blur(4px);
}
.install-sheet-panel {
  width: min(100%, 420px);
  max-height: 92dvh;
  overflow-y: auto;
  border-radius: 20px;
  background: var(--surface);
  padding: 28px 24px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  text-align: center;
}
.install-sheet-icon { border-radius: 18px; margin-bottom: 14px; }
.install-sheet-panel h2 { margin-bottom: 10px; font-size: 24px; }
.install-sheet-lead { margin: 0 0 18px; color: var(--body); font-size: 14px; }
.install-steps {
  margin: 0 0 20px;
  padding: 18px 18px 18px 38px;
  border-radius: 14px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  text-align: left;
}
.install-steps li { margin-bottom: 10px; }
.install-steps li:last-child { margin-bottom: 0; }
.install-steps strong { color: var(--navy-900); }
.install-sheet-actions { display: grid; gap: 10px; }

.mobile-nav { display: none; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast {
  max-width: 360px;
  border-radius: 12px;
  background: var(--navy-900);
  color: white;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

@media (max-width: 840px) {
  .topbar { min-height: 64px; padding-inline: 16px; }
  .brand strong { font-size: 16px; }
  .brand small { font-size: 9px; }
  .topbar-actions .button { padding-inline: 8px; font-size: 10px; }
  .workspace { display: block; min-height: calc(100dvh - 64px); }
  .sidebar { display: none !important; }
  .content { max-width: none; padding: 24px 16px calc(94px + env(safe-area-inset-bottom)); }
  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 1px solid var(--line);
    background: rgb(255 255 255 / 96%);
    padding-bottom: env(safe-area-inset-bottom);
    backdrop-filter: blur(18px);
  }
  .mobile-nav a { position: relative; display: grid; min-height: 62px; place-items: center; align-content: center; gap: 2px; color: var(--muted); }
  .mobile-nav a > span:first-child { font-size: 19px; line-height: 1; }
  .mobile-nav small { font-size: 10px; font-weight: 750; }
  .mobile-nav a.active { color: var(--navy-900); }
  .mobile-nav .badge { position: absolute; top: 7px; left: calc(50% + 7px); }
  .auth-layout { min-height: auto; grid-template-columns: 1fr; gap: 24px; }
  .auth-intro { padding-top: 12px; }
  .auth-intro h1 { font-size: 32px; }
  .auth-points { display: none; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field-full { grid-column: auto; }
}

@media (min-width: 841px) {
  .sidebar:not(.hidden) { display: flex; }
}

@media (max-width: 460px) {
  .brand small { display: none; }
  .topbar-actions { gap: 2px; }
  .card { padding: 20px 17px; }
  .install-card { align-items: stretch; flex-direction: column; }
  .message-meta { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: no-preference) {
  .message-item, .button { transition: .18s ease; }
}
