:root {
  --bg: #FAFAFA;
  --surface: #FFFFFF;
  --border: #DCE4E5;
  --ink: #1B4A5A;
  --muted: #55707A;
  --accent: #F6B26B;
  --accent-ink: #9A4E06;
  --on-accent: #1B4A5A;
  --peach: #FEEEDF;
  --mist: #C0CBCD;
  --space-pribadi: #1B4A5A;
  --space-anak: #F6B26B;
  --space-inbox: #C0CBCD;
  --graph-bg: #1B4A5A;
  --radius-btn: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --font-serif: Georgia, "Newsreader", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px;
}

.topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 960px;
  margin: 0 auto 10px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-bar {
  max-width: 960px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
}

.profile-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.profile-select {
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.offline-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--peach);
  padding: 4px 8px;
  border-radius: 8px;
}

.controls-area {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 14px;
  color: var(--ink);
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.pill {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

.view-section {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  flex: 1;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 720px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.card-preview {
  height: 108px;
  border-radius: 6px;
  background: var(--peach);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-snippet {
  padding: 10px;
  font-family: var(--font-serif);
  font-size: 12px;
  color: var(--ink);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  align-self: flex-start;
}

.badge-space {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  color: #FFFFFF;
}

.badge-image { background: #1B4A5A; }
.badge-audio { background: #F6B26B; color: #1B4A5A; }
.badge-link { background: #2F7A8C; }
.badge-video { background: #FEEEDF; color: #9A4E06; box-shadow: inset 0 0 0 1px #F6B26B; }
.badge-text { background: #C0CBCD; color: #1B4A5A; }

.card-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.card-type {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-topics {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.graph-section {
  padding: 16px;
  max-width: 1120px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg);
  color: var(--ink);
}

.graph-top-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topic-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.graph-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.graph-select,
.graph-month {
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 12px;
}

.dominant-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
}

.dominant-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 5px 12px;
  border-radius: var(--radius-btn);
  font-family: var(--font-mono);
  cursor: pointer;
}

.dominant-chip.top {
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}

.dominant-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.graph-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.graph-canvas-wrap {
  position: relative;
  height: 420px;
  background: var(--graph-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

#graphCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.graph-side-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  overflow-y: auto;
  max-height: 420px;
}

@media (min-width: 720px) {
  .graph-body {
    flex-direction: row;
    align-items: stretch;
  }

  .graph-canvas-wrap {
    width: 70%;
    height: 480px;
  }

  .graph-side-card {
    width: 30%;
    height: 480px;
    max-height: 480px;
  }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.drawer-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.drawer-entries {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drawer-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(27, 74, 90, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 20;
}

.nav-btn {
  min-width: 72px;
  min-height: 44px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-btn);
}

.nav-btn.active {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

.capture-fab {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transform: translateY(-10px);
  box-shadow: 0 0 0 4px #FFFFFF, 0 6px 14px rgba(27, 74, 90, 0.28);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 74, 90, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.bottom-sheet {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  padding: 12px 18px 28px;
  max-height: 88dvh;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(27, 74, 90, 0.2);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--mist);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sheet-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.mode-btn {
  min-height: 44px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--peach);
}

.capture-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

.audio-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-record {
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-btn);
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.record-status {
  font-size: 12px;
  color: var(--muted);
}

.space-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.space-opt {
  min-height: 40px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.space-opt.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #FFFFFF;
}

.btn-primary {
  min-height: 48px;
  border-radius: var(--radius-btn);
  border: none;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 24px;
}

.btn-secondary {
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.btn-text {
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  min-height: 36px;
  border-radius: var(--radius-btn);
  padding: 0 12px;
}

.btn-danger {
  margin-top: 14px;
  min-height: 42px;
  width: 100%;
  border-radius: var(--radius-btn);
  border: 1px solid #FECACA;
  background: #FEF2F2;
  color: #B91C1C;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.detail-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.detail-media img,
.detail-media audio,
.detail-media video {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 12px;
}

.detail-markdown {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pair-code {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  color: var(--ink);
  background: var(--peach);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 8px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.login-gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px 24px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(27, 74, 90, 0.08);
}

.login-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--accent);
}

.login-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.login-icon {
  border-radius: 10px;
  flex-shrink: 0;
}

.login-title {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

.login-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.login-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: #991B1B;
  font-size: 13px;
  padding: 10px 12px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 12px 16px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn-google:hover {
  background: var(--peach);
  border-color: var(--accent);
}

.btn-google:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.google-icon {
  flex-shrink: 0;
}

.login-note {
  margin-top: 16px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}
