/* Same design tokens as the extension — identical visual identity. */
:root {
  --bg: #121212;
  --surface: #1a1a1a;
  --surface-muted: #222222;
  --surface-hover: #262626;
  --border: #2f2f2f;
  --border-strong: #3a3a3a;
  --text: #f5f5f5;
  --text-muted: #a3a3a3;
  --accent: #ff7a1a;
  --accent-dark: #e5660a;
  --accent-soft: rgba(255, 122, 26, 0.14);
  --danger: #ffb278;
  --shadow: 0 4px 14px rgba(0,0,0,0.28);
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 160ms ease;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  height: 100%;
  overscroll-behavior: none;
}

body { min-height: 100dvh; }
button, input { font: inherit; }
a { color: inherit; }

/* ---- Screens ---- */
.screen { min-height: 100dvh; }

/* ---- Lock ---- */
.lock-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 400px;
  margin: 0 auto;
  padding: 60px 24px 24px;
}
.lock-title {
  font-size: 26px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}
.lock-sub {
  margin: -6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* ---- Loading ---- */
.loading-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 100dvh;
}
.loading-text { color: var(--text-muted); font-size: 14px; }
.spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Inputs / buttons ---- */
.text-input {
  width: 100%;
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 13px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.text-input:focus { border-color: var(--accent); }

.primary-btn {
  width: 100%;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  box-shadow: 0 4px 16px rgba(255,122,26,0.22);
}
.primary-btn:active { background: var(--accent-dark); }

.secondary-btn {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition);
  text-align: center;
}
.secondary-btn:active { background: var(--surface-hover); }
.secondary-btn--danger { color: var(--danger); border-color: rgba(255,178,120,0.25); }

.link-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 4px 6px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}
.link-btn:active { background: var(--surface-hover); }

.file-label { display: block; }

/* ---- Messages ---- */
.msg { min-height: 16px; font-size: 13px; color: var(--text-muted); }
.msg--error { color: var(--danger); }

.hint { font-size: 12px; color: var(--text-muted); margin-top: -8px; }
.divider { border: none; border-top: 1px solid var(--border); }

/* ---- App layout ---- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---- Header ---- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.app-title { font-size: 18px; font-weight: 700; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.icon-header-btn {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.icon-header-btn:active { background: var(--surface-hover); }

/* ---- Sync status ---- */
.sync-status {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.sync-status--local_only { color: var(--text-muted); border-color: var(--border); }
.sync-status--syncing    { color: var(--accent); border-color: var(--accent-soft); }
.sync-status--synced     { color: #6dc97c; border-color: rgba(109,201,124,0.25); }
.sync-status--error      { color: var(--danger); border-color: rgba(255,178,120,0.25); }

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px 4px;
  background: var(--bg);
}
.tab-button {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tab-button--active {
  background: var(--surface-muted);
  border-color: var(--border-strong);
  color: var(--text);
}

/* ---- List ---- */
.list-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  overflow-y: auto;
}

.empty-state {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  padding: 32px 20px;
  text-align: center;
  font-size: 14px;
  margin-top: 8px;
}

.link-item {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.link-main-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.link-title {
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.link-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.icon-btn:active { background: var(--surface-hover); color: var(--text); }
.icon-btn--accent { color: var(--accent); border-color: rgba(255,122,26,0.2); }
.icon-btn--accent:active { background: var(--accent-soft); }
.icon-btn--danger { color: var(--danger); border-color: rgba(255,178,120,0.2); }
.icon-btn--danger:active { background: rgba(255,178,120,0.1); }

.link-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}
.link-url {
  word-break: break-all;
  margin-top: 2px;
  font-size: 10px;
  opacity: 0.7;
}

/* ---- Footer ---- */
.app-footer {
  padding: 12px 16px;
  padding-bottom: max(12px, calc(var(--safe-bottom) + 12px));
  border-top: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  bottom: 0;
}

.add-btn {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface-muted);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 13px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}
.add-btn:active { background: var(--surface-hover); }

/* ---- Panels (full-screen overlays) ---- */
.panel {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 20;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  padding-top: max(18px, env(safe-area-inset-top, 18px));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}
.panel-title { font-size: 17px; font-weight: 700; }

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  padding-bottom: max(20px, calc(var(--safe-bottom) + 20px));
  max-width: 500px;
  width: 100%;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.col-btns { display: flex; flex-direction: column; gap: 10px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
