/* Prism Design System — Identity Partners */
/* @import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:wght@400;600;700&family=Merriweather:wght@400;700&family=DM+Sans:wght@300;400;500;600&family=Plus+Jakarta+Sans:wght@400;500;600&family=Lora:wght@400;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Brand Tokens (Parchment & Rose — default) ─────────────────────────────── */
:root {
  --bg-primary:   #f7f3e9;
  --bg-surface:   #f0e9e0;
  --bg-elevated:  #ffffff;
  --fg-primary:   #5c2d3f;
  --fg-secondary: #7a4254;
  --fg-muted:     #a88792;
  --border:       #ddd0c8;
  --accent:       #0f3b3a;
  --accent-hover: #1a5550;
  --accent-light: #e8f4f4;
  --rose:         #5c2d3f;
  --rose-light:   #f5e8ec;
  --success:      #5a7a4f;
  --warning:      #c4925a;
  --danger:       #8b3a3a;
  --sidebar-w:    240px;
  --sidebar-w-collapsed: 56px;
  --topbar-h:     56px;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(92,45,63,0.08), 0 4px 12px rgba(92,45,63,0.06);
  --shadow-lg:    0 8px 32px rgba(92,45,63,0.12);
  --font-ui:      'Inter', system-ui, sans-serif;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-quote:   'Merriweather', Georgia, serif;
  --font-mono:    'JetBrains Mono', 'Courier New', monospace;
  --transition:   0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--fg-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font-ui); }
input, textarea, select { font-family: var(--font-ui); }

/* ── Layout Shell ───────────────────────────────────────────────────────────── */
.prism-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
  flex-shrink: 0;
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}
.sidebar-logo-mark {
  width: 28px; height: 28px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo-mark svg { width: 28px; height: 28px; }
.sidebar-logo-text {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition);
}
.sidebar.collapsed .sidebar-logo-text { opacity: 0; pointer-events: none; }
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}
.sidebar-section {
  padding: 16px 14px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .sidebar-section { opacity: 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 0;
  color: var(--fg-secondary);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-decoration: none;
  position: relative;
}
.nav-item:hover { background: var(--accent-light); color: var(--accent); text-decoration: none; }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.nav-item-label {
  transition: opacity var(--transition);
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar.collapsed .nav-item-label { opacity: 0; pointer-events: none; }
.nav-sub { padding-left: 28px; }
.nav-sub .nav-item { font-size: 12.5px; padding: 6px 14px 6px 0; }
.sidebar-toggle {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-shrink: 0;
}
.sidebar-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--fg-muted);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.sidebar-toggle-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ── Main Content ───────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-w-collapsed); }

/* ── Top Bar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}
.topbar-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--fg-primary);
  flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 8px; }

/* ── Page Content ───────────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.page-content.full-width { max-width: none; padding: 0; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg-primary);
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: var(--font-ui);
  line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-secondary {
  background: var(--bg-surface);
  color: var(--fg-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.btn-rose {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}
.btn-rose:hover { background: #7a3a50; border-color: #7a3a50; color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--fg-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--accent-light); color: var(--accent); }
.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-icon { padding: 7px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Inputs ─────────────────────────────────────────────────────────────────── */
.input, .textarea, .select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg-primary);
  font-size: 13.5px;
  font-family: var(--font-ui);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,59,58,0.1);
}
.input::placeholder, .textarea::placeholder { color: var(--fg-muted); }
.textarea {
  min-height: 80px;
  resize: vertical;
  line-height: 1.6;
}
.textarea-lg { min-height: 160px; }
.input-group {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-secondary);
  margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
}
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-rose { background: var(--rose-light); color: var(--rose); }
.badge-success { background: #edf5eb; color: var(--success); }
.badge-warning { background: #fdf3e7; color: var(--warning); }
.badge-danger { background: #fbeaea; color: var(--danger); }
.badge-muted { background: var(--bg-surface); color: var(--fg-muted); }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--fg-primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(92,45,63,0.3);
  backdrop-filter: blur(2px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: var(--font-heading); font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab:hover { color: var(--fg-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Chips ──────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover, .chip.active { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }

/* ── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Markdown Rendering ─────────────────────────────────────────────────────── */
.md-content h1 { font-family: var(--font-heading); font-size: 22px; font-weight: 600; margin: 20px 0 12px; color: var(--fg-primary); }
.md-content h2 { font-family: var(--font-heading); font-size: 18px; font-weight: 600; margin: 18px 0 10px; color: var(--fg-primary); }
.md-content h3 { font-size: 15px; font-weight: 600; margin: 14px 0 8px; color: var(--fg-primary); }
.md-content p { margin-bottom: 12px; line-height: 1.7; }
.md-content ul, .md-content ol { margin: 8px 0 12px 20px; }
.md-content li { margin-bottom: 4px; line-height: 1.6; }
.md-content code { font-family: var(--font-mono); font-size: 12.5px; background: var(--bg-surface); padding: 2px 6px; border-radius: 4px; color: var(--rose); }
.md-content pre { background: var(--fg-primary); color: #f0e9e0; padding: 16px; border-radius: var(--radius-sm); overflow-x: auto; margin: 12px 0; }
.md-content pre code { background: none; color: inherit; padding: 0; }
.md-content blockquote { border-left: 3px solid var(--accent); padding: 8px 16px; margin: 12px 0; background: var(--accent-light); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-family: var(--font-quote); font-style: italic; }
.md-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.md-content th { background: var(--bg-surface); padding: 8px 12px; text-align: left; font-weight: 600; border: 1px solid var(--border); }
.md-content td { padding: 8px 12px; border: 1px solid var(--border); }
.md-content tr:nth-child(even) td { background: var(--bg-surface); }
.md-content hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.md-content strong { font-weight: 600; }
.md-content em { font-style: italic; }
.md-content a { color: var(--accent); }

/* ── World Clocks ───────────────────────────────────────────────────────────── */
.world-clocks {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 11.5px;
  color: var(--fg-muted);
}
.world-clock-item { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.world-clock-time { font-weight: 600; color: var(--fg-secondary); font-size: 12px; }
.world-clock-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Pomodoro ───────────────────────────────────────────────────────────────── */
.pomodoro {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--fg-secondary);
}
.pomodoro-time { font-weight: 600; font-size: 14px; font-family: var(--font-mono); }
.pomodoro-btn { background: none; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; font-size: 11px; cursor: pointer; color: var(--fg-muted); }
.pomodoro-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── On-screen Keyboard ─────────────────────────────────────────────────────── */
.osk {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  user-select: none;
  flex-shrink: 0;
}
.osk-row {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  justify-content: center;
}
.osk-row:last-child { margin-bottom: 0; }
.osk-key {
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s;
  font-family: var(--font-ui);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.osk-key:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.osk-key:active { transform: translateY(1px); box-shadow: none; }
.osk-key.wide { min-width: 56px; }
.osk-key.wider { min-width: 80px; }
.osk-key.space { min-width: 160px; }
.osk-key.send { background: var(--accent); color: #fff; border-color: var(--accent); min-width: 56px; }
.osk-key.send:hover { background: var(--accent-hover); }
.osk-key.enter { background: var(--bg-surface); min-width: 56px; }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* ── Tooltips ───────────────────────────────────────────────────────────────── */
[title] { position: relative; }
.tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--fg-primary);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 1000;
}
[title]:hover .tooltip { opacity: 1; }

/* ── Divider ────────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.divider-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg-muted);
  font-size: 11px;
  margin: 16px 0;
}
.divider-label::before, .divider-label::after { content: ''; flex: 1; border-top: 1px solid var(--border); }

/* ── Grid ───────────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .sidebar-logo-text, .sidebar .nav-item-label, .sidebar .sidebar-section { opacity: 0; pointer-events: none; }
  .main-content { margin-left: var(--sidebar-w-collapsed); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: none; width: var(--sidebar-w); }
  .sidebar.mobile-open .sidebar-logo-text, .sidebar.mobile-open .nav-item-label, .sidebar.mobile-open .sidebar-section { opacity: 1; pointer-events: auto; }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

/* ── Utility ────────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--fg-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-heading { font-family: var(--font-heading); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }