:root {
  --accent: #6d8dfc;
  --bg: oklch(14% 0.012 260);
  --surface: oklch(19% 0.012 260);
  --surface-2: oklch(17.5% 0.012 260);
  --border: oklch(26% 0.014 260);
  --border-strong: oklch(32% 0.014 260);
  --text: oklch(95% 0.005 260);
  --text-secondary: oklch(68% 0.012 260);
  --text-tertiary: oklch(52% 0.012 260);
  --danger: oklch(65% 0.18 25);
  --warn: oklch(75% 0.14 80);
  --success: oklch(70% 0.15 145);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans KR', 'Malgun Gothic', system-ui, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); }
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.brand-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  display: flex; align-items: center; justify-content: center;
}
.brand-icon.small { width: 30px; height: 30px; border-radius: 9px; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-name.small { font-size: 15.5px; }

.auth-tabs { display: flex; border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 3px; }
.auth-tab {
  flex: 1; background: transparent; border: none; color: var(--text-secondary);
  padding: 8px 0; border-radius: 8px; font-size: 13.5px; font-weight: 600;
}
.auth-tab.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-error {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger); font-size: 12.5px; padding: 9px 12px; border-radius: 8px;
}
.auth-footer { text-align: center; font-size: 11.5px; color: var(--text-tertiary); }

.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-top: 6px; }
.field-hint { font-size: 11.5px; color: var(--text-tertiary); line-height: 1.5; }
.field-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }

.input, .textarea {
  width: 100%; height: 42px; border-radius: 10px; border: 1px solid var(--border);
  background: oklch(12% 0.01 260); color: var(--text); font-size: 14px; padding: 0 14px;
}
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.input.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.textarea { height: auto; min-height: 70px; padding: 10px 14px; resize: vertical; }

.input-icon-wrap { position: relative; }
.input-icon-wrap .input { padding-right: 42px; }
.eye-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent;
  color: var(--text-tertiary); display: flex; align-items: center; justify-content: center;
}
.eye-toggle:hover { background: var(--border); }

.btn-primary {
  height: 44px; border: none; border-radius: 10px; background: var(--accent);
  color: oklch(15% 0.01 260 / 92%); font-size: 14.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary {
  height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: transparent; color: var(--text); font-size: 13px; font-weight: 600;
}
.btn-secondary:hover { background: var(--border); }
.btn-secondary.btn-small { height: 34px; padding: 0 12px; font-size: 12.5px; }
.btn-danger {
  height: 40px; border: none; border-radius: 9px; background: var(--danger);
  color: oklch(15% 0 0 / 90%); font-weight: 700; font-size: 13px;
}
.link-btn { background: none; border: none; color: var(--accent); font-size: 11.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; }

/* ---- Dashboard shell ---- */
.dash { display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  height: 60px; min-height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 18px; border-bottom: 1px solid var(--border); background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.menu-toggle { display: none; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: none; background: transparent;
  color: var(--text-secondary); display: flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--border); color: var(--text); }
.topbar-search { position: relative; flex: 1; max-width: 460px; margin: 0 auto; }
.topbar-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); }
.topbar-search input {
  width: 100%; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 13.5px; padding: 0 14px 0 36px;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}

.dash-body { flex: 1; display: flex; position: relative; overflow: hidden; }
.sidebar {
  width: 252px; min-width: 252px; padding: 18px 14px; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.btn-add { width: 100%; }
.category-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; padding: 9px 10px;
  border-radius: 8px; cursor: pointer; color: var(--text-secondary); font-size: 13.5px;
}
.nav-item:hover { background: var(--border); }
.nav-item.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; }
.nav-item .nav-left { display: flex; align-items: center; gap: 10px; }
.nav-count { font-size: 11.5px; color: var(--text-tertiary); }
.nav-item.active .nav-count { color: var(--accent); font-weight: 600; }
.sidebar-spacer { flex: 1; }
.sidebar-backdrop { display: none; }

.content { flex: 1; padding: 20px 24px; overflow-y: auto; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.content-title { font-size: 18px; font-weight: 700; }
.content-subtitle { font-size: 12.5px; color: var(--text-tertiary); margin-top: 3px; }

.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2);
}
.entry-row:hover { border-color: var(--border-strong); }
.entry-avatar {
  width: 38px; height: 38px; min-width: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700;
}
.entry-main { flex: 1; min-width: 0; }
.entry-site { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-user { font-size: 12.5px; color: var(--text-tertiary); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-chip { font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.entry-actions { display: flex; align-items: center; gap: 2px; }
.empty-state { text-align: center; color: var(--text-tertiary); font-size: 13.5px; margin-top: 60px; }

/* ---- Modals ---- */
.modal-overlay {
  position: fixed; inset: 0; background: oklch(8% 0 0 / 62%);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px 24px 20px; box-shadow: 0 30px 70px rgba(0,0,0,0.5);
}
.settings-card { max-width: 560px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.category-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  color: var(--text-secondary); cursor: pointer;
}
.chip.selected { background: var(--accent); color: oklch(15% 0.01 260 / 92%); border-color: transparent; font-weight: 600; }

.strength-row { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.strength-bar { display: flex; gap: 3px; flex: 1; height: 4px; }
.strength-bar span { display: block; height: 4px; border-radius: 2px; background: var(--border-strong); flex: 1; }
.strength-label { font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--text-tertiary); }

/* ---- Settings ---- */
.settings-scroll { display: flex; flex-direction: column; gap: 4px; }
.settings-section { padding: 14px 0; border-top: 1px solid var(--border); }
.settings-section:first-child { border-top: none; padding-top: 0; }
.settings-section-title { font-size: 12.5px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 10px; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.settings-row-title { font-size: 13.5px; font-weight: 600; }
.settings-row-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.settings-form { display: flex; flex-direction: column; gap: 8px; }
.danger-section .danger-title { color: var(--danger); }
.invite-row { padding-bottom: 4px; }
.invite-code-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.invite-item {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 9px; font-size: 13px;
}
.invite-code-text { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.invite-code-text.inactive { color: var(--text-tertiary); text-decoration: line-through; }
.user-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.user-item {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 9px; font-size: 13px;
}
.user-item-name { font-weight: 600; }
.user-item-sub { font-size: 11.5px; color: var(--text-tertiary); }
.badge-admin {
  font-size: 10.5px; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent); padding: 2px 7px; border-radius: 999px; margin-left: 6px;
}

.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute; cursor: pointer; inset: 0; background: var(--border-strong); border-radius: 999px; transition: 0.15s;
}
.switch-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: 0.15s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size: 13px; z-index: 200; box-shadow: 0 12px 30px rgba(0,0,0,0.4);
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .menu-toggle { display: flex; }
  .sidebar {
    position: fixed; top: 60px; left: 0; bottom: 0; z-index: 60; background: var(--bg);
    transform: translateX(-100%); transition: transform 0.18s ease; width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.open {
    display: block; position: fixed; inset: 60px 0 0 0; background: rgba(0,0,0,0.5); z-index: 50;
  }
  .topbar-search { margin: 0 8px; }
  .content { padding: 16px; }
  .entry-chip { display: none; }
}
@media (max-width: 480px) {
  .auth-card { padding: 28px 20px 22px; }
  .entry-actions .icon-btn { width: 28px; height: 28px; }
  .modal-card { padding: 18px 16px 16px; }
}
