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

:root {
  --bg:        #f8f7f4;
  --surface:   #ffffff;
  --border:    #e5e2db;
  --text:      #1a1a1a;
  --muted:     #888;
  --hint:      #bbb;
  --accent:    #534AB7;
  --accent-bg: #EEEDFE;
  --accent-t:  #3C3489;
  --danger:    #A32D2D;
  --danger-bg: #FCEBEB;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Login ── */
.screen { width: 100%; }

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.login-card h1 { font-size: 20px; font-weight: 500; margin-bottom: 6px; }
.login-sub     { font-size: 13px; color: var(--muted); margin-bottom: 1.75rem; }
.login-hint    { font-size: 12px; color: var(--hint); margin-top: 1.25rem; }

.user-btns { display: flex; gap: 12px; justify-content: center; }

.user-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 1.25rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.15s;
}
.user-btn:hover { background: var(--bg); border-color: #ccc; transform: translateY(-1px); }

.user-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
}

/* ── App Header ── */
.page { max-width: 680px; margin: 0 auto; padding: 0 1rem 4rem; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.header-left { display: flex; align-items: center; gap: 10px; }
.header-left h1 { font-size: 17px; font-weight: 500; }

.user-badge {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}

.header-right { display: flex; gap: 4px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: all 0.15s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }

/* ── Draw Section ── */
.draw-section { margin-bottom: 2rem; }

.count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 0.875rem;
}
.count-lbl  { font-size: 13px; color: var(--muted); }
.count-btns { display: flex; gap: 5px; flex-wrap: wrap; }

.cnt-btn {
  font-size: 13px; font-weight: 500;
  padding: 4px 13px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all 0.15s;
}
.cnt-btn:hover  { background: var(--bg); }
.cnt-btn.active { background: var(--accent); color: #EEEDFE; border-color: var(--accent); }

.draw-btn {
  width: 100%;
  padding: 12px;
  font-size: 15px; font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; margin-bottom: 1rem;
  transition: all 0.15s;
}
.draw-btn:hover  { background: var(--bg); }
.draw-btn:active { transform: scale(0.99); }

.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.25rem;
  min-height: 90px;
  margin-bottom: 0.75rem;
}

.empty-hint { color: var(--hint); font-size: 13px; text-align: center; padding: 1.25rem 0; }

.tag {
  font-size: 12px; padding: 4px 12px;
  border-radius: 999px; font-weight: 500;
  border: 1px solid transparent;
  display: inline-block;
}

.cat-badge {
  font-size: 11px; padding: 2px 8px;
  border-radius: 999px; border: 1px solid transparent;
}

.action-row  { display: flex; gap: 8px; flex-wrap: wrap; }

.act-btn {
  flex: 1; min-width: 100px;
  padding: 9px 14px; font-size: 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  cursor: pointer; transition: all 0.15s;
  white-space: nowrap;
}
.act-btn:hover           { background: var(--bg); }
.act-btn--primary        { background: var(--accent); color: white; border-color: var(--accent); }
.act-btn--primary:hover  { opacity: 0.88; }
.act-btn--danger         { color: var(--danger); border-color: #f0bebe; }
.act-btn--danger:hover   { background: var(--danger-bg); }

/* ── Tabs ── */
.tab-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  gap: 0;
}

.tab {
  flex: 1; padding: 10px 8px; font-size: 13px; font-weight: 500;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Record List ── */
.record-list { display: flex; flex-direction: column; gap: 8px; }

.empty-records {
  text-align: center; color: var(--hint);
  font-size: 13px; padding: 2rem 0;
}

.record-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.875rem 1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.record-item:hover { border-color: #ccc; background: #fdfcfa; }

.record-item-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.record-item-meta { font-size: 11px; color: var(--hint); }
.record-shared-badge {
  font-size: 10px; padding: 2px 7px; border-radius: 999px;
  background: #E1F5EE; color: #085041; border: 1px solid #9FE1CB;
}

.record-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.record-note {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.load-more-btn {
  width: 100%; padding: 9px; font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s; margin-top: 4px;
}
.load-more-btn:hover { background: var(--surface); }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 100;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 1.5rem;
  width: 100%; max-width: 420px;
  max-height: 90vh; overflow-y: auto;
}
.modal-card--wide { max-width: 520px; }

.modal-card h2 { font-size: 17px; font-weight: 500; margin-bottom: 1.25rem; }

.setting-row { margin-bottom: 1rem; }
.setting-row label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.setting-row input {
  width: 100%; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text); outline: none;
}
.setting-row input:focus { border-color: var(--accent); }

.modal-actions { display: flex; gap: 8px; margin-top: 1rem; }

.detail-header { font-size: 13px; color: var(--muted); }
.detail-note textarea {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg); color: var(--text);
  resize: vertical; font-family: inherit; outline: none;
}
.detail-note textarea:focus { border-color: var(--accent); }

.shared-header { margin-bottom: 1rem; }
.shared-desc { font-size: 13px; color: var(--muted); }

/* ── Toast ── */
#toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: #1a1a1a; color: white;
  padding: 9px 18px; border-radius: 999px;
  font-size: 13px; z-index: 200;
  opacity: 0; transition: opacity 0.2s;
  pointer-events: none; white-space: nowrap;
}
#toast.show { opacity: 1; }

/* ── Anim ── */
@keyframes pop {
  0%   { opacity: 0.4; transform: scale(0.96); }
  100% { opacity: 1;   transform: scale(1); }
}
.anim { animation: pop 0.22s ease; }

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

/* ── Main Tabs ── */
.main-tab-row {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.main-tab {
  flex: 1; padding: 10px 6px; font-size: 13px; font-weight: 500;
  border: none; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted);
  cursor: pointer; transition: all 0.15s; margin-bottom: -1px;
}
.main-tab:hover { color: var(--text); }
.main-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Browse ── */
.browse-header {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 8px; margin-bottom: 1rem;
}
.browse-desc { font-size: 13px; color: var(--muted); flex: 1; min-width: 160px; }
.browse-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.browse-count-badge {
  font-size: 12px; color: var(--accent); font-weight: 500;
  background: var(--accent-bg); padding: 3px 10px;
  border-radius: 999px; white-space: nowrap;
}
.browse-selected-bar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px;
  margin-bottom: 1rem;
}
.browse-selected-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.browse-cat-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 1rem 1.1rem;
  margin-bottom: 0.875rem;
}
.browse-cat-header {
  display: flex; align-items: center; gap: 7px; margin-bottom: 4px;
}
.browse-cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.browse-cat-name { font-size: 14px; font-weight: 500; color: var(--text); }
.browse-cat-count {
  font-size: 11px; color: var(--hint); background: var(--bg);
  border-radius: 999px; padding: 1px 7px; border: 1px solid var(--border);
  margin-left: auto;
}
.browse-cat-desc { font-size: 12px; color: var(--muted); margin-bottom: 0.75rem; line-height: 1.5; }
.browse-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.browse-tag {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  font-weight: 500; border: 1px solid transparent;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.browse-tag:hover { filter: brightness(0.93); }
.browse-tag--selected { outline: 2.5px solid var(--accent); outline-offset: 1px; }

/* ── Record item actions ── */
.record-item-actions {
  display: flex; gap: 6px; margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.record-action-btn {
  font-size: 12px; padding: 4px 10px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.record-action-btn:hover { background: var(--bg); color: var(--text); }
.record-action-btn--claude {
  color: var(--accent); border-color: #d0ccf0; background: var(--accent-bg);
}
.record-action-btn--claude:hover { opacity: 0.85; }
