/* ==========================================================================
   InOut AI — Apple-inspired Design System
   Reference: Apple HIG Typography, Apple System Colors, Mobbin Apple Brand
   Palette: Black / White / Gray only (no color, no emoji)
   Type: SF Pro scale (Large Title 34 / Title 17 Medium / Body 17 / Sub 15 / Caption 13)
   ========================================================================== */

:root {
  /* Neutral palette — Apple system grays + brand neutrals */
  --black: #1d1d1f;          /* Shark (Apple brand near-black) */
  --true-black: #000000;
  --white: #ffffff;
  --bg: #f5f5f7;             /* Athens Gray (Apple page bg) */
  --bg-elevated: #ffffff;
  --gray-1: #8e8e93;         /* systemGray */
  --gray-2: #aeaeb2;         /* systemGray2 */
  --gray-3: #c7c7cc;         /* systemGray3 */
  --gray-4: #d1d1d6;         /* systemGray4 */
  --gray-5: #e5e5ea;         /* systemGray5 */
  --gray-6: #f2f2f7;         /* systemGray6 */

  --label: #1d1d1f;          /* primary label */
  --label-secondary: #6e6e73;
  --label-tertiary: #8e8e93;
  --label-quaternary: #aeaeb2;

  --separator: rgba(0,0,0,0.10);
  --separator-opaque: #d1d1d6;

  --fill-quaternary: rgba(116,116,128,0.08);
  --fill-tertiary: rgba(116,116,128,0.12);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.10);

  --sidebar-w: 248px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Pretendard", "Apple SD Gothic Neo", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.47;
  letter-spacing: -0.01em;
}

/* Type scale (Apple SF Pro) */
.t-large { font-size: 34px; font-weight: 700; letter-spacing: 0.011em; line-height: 1.12; }
.t-title { font-size: 22px; font-weight: 600; letter-spacing: -0.012em; line-height: 1.2; }
.t-title2 { font-size: 19px; font-weight: 600; letter-spacing: -0.014em; }
.t-headline { font-size: 17px; font-weight: 600; letter-spacing: -0.022em; }
.t-body { font-size: 15px; font-weight: 400; letter-spacing: -0.016em; }
.t-sub { font-size: 13px; font-weight: 400; letter-spacing: -0.006em; color: var(--label-secondary); }
.t-caption { font-size: 11px; font-weight: 500; letter-spacing: 0.004em; color: var(--label-tertiary); text-transform: uppercase; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===================== App shell ===================== */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--separator);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 20;
}
.sidebar-brand {
  padding: 20px 20px 14px;
  display: flex; align-items: center; gap: 10px;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--black); color: var(--white);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: -0.03em;
}
.brand-name { font-size: 16px; font-weight: 650; letter-spacing: -0.02em; }

.workspace-switch {
  margin: 0 12px 12px; padding: 9px 12px;
  background: var(--gray-6); border: 1px solid var(--separator);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: background .15s;
}
.workspace-switch:hover { background: var(--gray-5); }
.ws-avatar {
  width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0;
  background: var(--black); color: var(--white);
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.ws-meta { overflow: hidden; }
.ws-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-plan { font-size: 11px; color: var(--label-tertiary); }

.nav { padding: 4px 10px 12px; }
.nav-group { margin-bottom: 14px; }
.nav-group-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  color: var(--label-quaternary); text-transform: uppercase;
  padding: 4px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--label-secondary); font-size: 14px; font-weight: 500;
  transition: background .12s, color .12s; cursor: pointer;
}
.nav-item:hover { background: var(--gray-6); color: var(--label); }
.nav-item.active { background: var(--black); color: var(--white); }
.nav-item .nav-ic { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item.active .nav-ic { stroke: var(--white); }

.sidebar-footer { margin-top: auto; padding: 12px; }
.credit-box {
  background: var(--gray-6); border: 1px solid var(--separator);
  border-radius: var(--radius); padding: 12px 14px;
}
.credit-row { display: flex; justify-content: space-between; align-items: baseline; }
.credit-amt { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.credit-label { font-size: 11px; color: var(--label-tertiary); }
.btn-upgrade {
  width: 100%; margin-top: 10px; padding: 8px;
  background: var(--black); color: var(--white);
  border: none; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  transition: opacity .15s;
}
.btn-upgrade:hover { opacity: 0.85; }

/* Main */
.main {
  flex: 1; margin-left: var(--sidebar-w);
  display: flex; flex-direction: column; min-width: 0;
}
.topbar {
  height: 56px; flex-shrink: 0;
  background: rgba(255,255,255,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--separator);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 15;
}
.topbar-title { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--label-secondary); font-size: 14px; margin-top: 4px; }

/* ===================== Components ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; border: 1px solid transparent;
  transition: background .15s, opacity .15s, border-color .15s;
}
.btn-primary { background: var(--black); color: var(--white); }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--white); color: var(--label); border-color: var(--separator-opaque); }
.btn-secondary:hover { background: var(--gray-6); }
.btn-ghost { background: transparent; color: var(--label-secondary); }
.btn-ghost:hover { background: var(--gray-6); color: var(--label); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn .ic { width: 16px; height: 16px; }

.card {
  background: var(--white); border: 1px solid var(--separator);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px){ .grid-4{grid-template-columns:repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 720px){ .grid-2,.grid-3,.grid-4{grid-template-columns:1fr;} }

.stat {
  background: var(--white); border: 1px solid var(--separator);
  border-radius: var(--radius-lg); padding: 18px 20px;
}
.stat-label { font-size: 12.5px; color: var(--label-secondary); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; margin-top: 6px; }
.stat-unit { font-size: 14px; font-weight: 500; color: var(--label-tertiary); margin-left: 3px; }
.stat-sub { font-size: 12px; color: var(--label-tertiary); margin-top: 4px; }

.tabs { display: flex; gap: 4px; background: var(--gray-6); padding: 3px; border-radius: 10px; width: fit-content; }
.tab {
  padding: 7px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  color: var(--label-secondary); border: none; background: transparent; transition: all .15s;
}
.tab.active { background: var(--white); color: var(--label); box-shadow: var(--shadow-sm); font-weight: 600; }

/* Form */
.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
.field-label .req { color: var(--label-tertiary); margin-left: 2px; }
.field-hint { font-size: 12.5px; color: var(--label-tertiary); margin-top: 6px; }
.input, .textarea, .select {
  width: 100%; padding: 10px 13px; font-size: 14px;
  background: var(--white); border: 1px solid var(--separator-opaque);
  border-radius: var(--radius-sm); color: var(--label);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.input::placeholder, .textarea::placeholder { color: var(--label-quaternary); }
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }

/* Toggle */
.toggle { position: relative; width: 44px; height: 26px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute; inset: 0; background: var(--gray-3);
  border-radius: 13px; transition: background .2s; cursor: pointer;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 22px; height: 22px; background: var(--white);
  border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-track { background: var(--black); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* Range slider */
input[type=range] {
  -webkit-appearance: none; width: 100%; height: 4px;
  background: var(--gray-4); border-radius: 2px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--white); border: 1px solid var(--gray-3);
  box-shadow: var(--shadow-sm); cursor: pointer;
}

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.02em; color: var(--label-tertiary);
  padding: 10px 14px; border-bottom: 1px solid var(--separator);
}
.table td { padding: 13px 14px; font-size: 13.5px; border-bottom: 1px solid var(--separator); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-6); }

/* Empty state */
.empty {
  text-align: center; padding: 56px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.empty-icon {
  width: 56px; height: 56px; border-radius: 16px;
  background: var(--gray-6); display: grid; place-items: center; margin-bottom: 6px;
}
.empty-icon svg { width: 26px; height: 26px; stroke: var(--gray-1); }
.empty h3 { font-size: 17px; font-weight: 650; }
.empty p { font-size: 14px; color: var(--label-secondary); max-width: 380px; }

/* Badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--gray-6); color: var(--label-secondary); border: 1px solid var(--separator);
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--gray-1); }
.badge.on { background: var(--black); color: var(--white); }
.badge.on .badge-dot { background: var(--white); }

/* Choice cards (agent type / mode) */
.choice-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
@media (max-width: 820px){ .choice-grid{grid-template-columns:1fr;} }
.choice {
  background: var(--white); border: 1.5px solid var(--separator-opaque);
  border-radius: var(--radius-lg); padding: 22px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.choice:hover { border-color: var(--gray-1); box-shadow: var(--shadow); transform: translateY(-1px); }
.choice.selected { border-color: var(--black); box-shadow: 0 0 0 3px rgba(0,0,0,0.06); }
.choice-ic { width: 40px; height: 40px; border-radius: 11px; background: var(--gray-6); display: grid; place-items: center; margin-bottom: 14px; }
.choice-ic svg { width: 21px; height: 21px; stroke: var(--black); }
.choice h3 { font-size: 16px; font-weight: 650; margin-bottom: 5px; }
.choice p { font-size: 13px; color: var(--label-secondary); line-height: 1.45; }

/* Builder layout */
.builder { display: grid; grid-template-columns: 1fr 380px; gap: 0; height: calc(100vh - 56px); }
@media (max-width: 1100px){ .builder{grid-template-columns:1fr;} }
.builder-main { overflow-y: auto; padding: 24px 28px; }
.builder-test {
  border-left: 1px solid var(--separator); background: var(--white);
  display: flex; flex-direction: column; overflow: hidden;
}
.section {
  background: var(--white); border: 1px solid var(--separator);
  border-radius: var(--radius-lg); margin-bottom: 14px; overflow: hidden;
}
.section-head {
  padding: 16px 20px; display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; user-select: none;
}
.section-head h3 { font-size: 15px; font-weight: 650; }
.section-head p { font-size: 12.5px; color: var(--label-tertiary); margin-top: 2px; }
.section-body { padding: 0 20px 20px; }

.divider { height: 1px; background: var(--separator); margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--separator); }
.row:last-child { border-bottom: none; }
.row-meta h4 { font-size: 14px; font-weight: 600; }
.row-meta p { font-size: 12.5px; color: var(--label-tertiary); margin-top: 3px; max-width: 460px; }

/* Auth pages — split layout (form + aside) */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; margin: auto; padding: 48px 40px; align-self: center; justify-self: center; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; }
.auth-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.auth-sub { color: var(--label-secondary); font-size: 14.5px; margin: 6px 0 26px; }
.auth-footer { font-size: 13.5px; color: var(--label-secondary); margin-top: 22px; }
.auth-footer a { font-weight: 600; color: var(--black); }
@media (max-width: 820px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}

.value-grid { display:grid; gap: 1px; background: var(--separator); border-radius: var(--radius); overflow:hidden; border:1px solid var(--separator); }
.value-grid .vg-cell { background: var(--white); padding: 16px 18px; }
.vg-cell .k { font-size: 12px; color: var(--label-tertiary); }
.vg-cell .v { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; margin-top: 3px; }

.spinner { width: 18px; height: 18px; border: 2px solid var(--gray-4); border-top-color: var(--black); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
.mono { font-family: "SF Mono", ui-monospace, "Menlo", monospace; font-size: 13px; }

/* ============ Settings layout ============ */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.settings-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--label-secondary); font-size: 14px; text-decoration: none;
}
.settings-nav-item .ic { width: 17px; height: 17px; }
.settings-nav-item:hover { background: var(--gray-6); color: var(--label); }
.settings-nav-item.active { background: var(--black); color: #fff; }
.settings-body { min-width: 0; }

/* ============ Voice cards ============ */
.voice-card { }
.voice-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.voice-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--gray-6); display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.voice-avatar .ic { width: 20px; height: 20px; color: var(--label-secondary); }
.voice-name { font-size: 15px; font-weight: 600; }
.voice-tag { display: flex; gap: 6px; margin-top: 4px; }
.voice-play { margin-left: auto; }
.voice-desc { font-size: 13.5px; color: var(--label-secondary); line-height: 1.5; }

/* ============ Upload zone ============ */
.upload-zone {
  border: 1.5px dashed var(--separator); border-radius: var(--radius);
  padding: 28px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--gray-1); background: var(--gray-6); }
.upload-ic { display: flex; justify-content: center; margin-bottom: 8px; }
.upload-ic .ic { width: 26px; height: 26px; color: var(--label-tertiary); }
.upload-zone p { font-size: 14px; color: var(--label); }
.upload-hint { font-size: 12px; color: var(--label-tertiary); }

/* ============ Checkboxes ============ */
.check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--label-secondary); cursor: pointer; }
.check-row input { width: 15px; height: 15px; accent-color: var(--black); }

/* ============ Filter bar ============ */
.filter-bar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

/* ============ Badge variant ============ */
.badge-warn { background: var(--gray-6); color: var(--label); }
.badge-warn .badge-dot { background: var(--label-tertiary); }

/* ============ Plans ============ */
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.plan-card {
  position: relative; background: var(--bg-elevated); border: 1px solid var(--separator);
  border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column;
}
.plan-card.current { border-color: var(--black); box-shadow: 0 0 0 1px var(--black); }
.plan-badge {
  position: absolute; top: 14px; right: 14px; font-size: 11px; font-weight: 600;
  background: var(--black); color: #fff; padding: 3px 8px; border-radius: 20px;
}
.plan-name { font-size: 16px; font-weight: 600; }
.plan-price { font-size: 26px; font-weight: 700; margin: 6px 0 2px; }
.plan-unit { font-size: 14px; font-weight: 400; color: var(--label-tertiary); }
.plan-desc { font-size: 13px; color: var(--label-secondary); margin-bottom: 14px; }
.plan-feats { list-style: none; padding: 0; margin: 0 0 16px; flex: 1; }
.plan-feats li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--label-secondary); padding: 4px 0; }
.plan-feats li .ic { width: 15px; height: 15px; color: var(--label); flex: 0 0 auto; }

/* ============ Auth aside / extras ============ */
.btn-block { width: 100%; justify-content: center; margin-top: 6px; }
.auth-err { color: #b00020; font-size: 13px; margin-top: 10px; min-height: 16px; }
.auth-aside {
  background: var(--black); color: #fff; padding: 48px 44px;
  display: flex; flex-direction: column; justify-content: center;
}
.auth-aside h2 { font-size: 26px; font-weight: 700; line-height: 1.25; margin-bottom: 14px; letter-spacing: -0.02em; }
.auth-aside > p { font-size: 15px; color: rgba(255,255,255,0.7); line-height: 1.6; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; }
.auth-points li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: rgba(255,255,255,0.9); padding: 7px 0; }
.auth-points li .ic { width: 18px; height: 18px; color: #fff; flex: 0 0 auto; }

.status-row { display: flex; gap: 8px; }
.row { display: flex; gap: 12px; align-items: flex-end; }
.code { font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.hidden { display: none !important; }

@media (max-width: 900px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; position: static; }
  .plan-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: 1fr; }
}

/* ============ Admin ============ */
.admin-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.08em; background: var(--black); color: #fff; padding: 1px 5px; border-radius: 4px; margin-left: 4px; vertical-align: middle; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--label-secondary); padding: 8px 0; border-bottom: 1px solid var(--separator); }
.check-list li:last-child { border-bottom: none; }
.check-list li .ic { width: 18px; height: 18px; flex: 0 0 auto; color: var(--label-tertiary); }
.check-list li .ic.ok { color: var(--black); }
