/*
 * Shared by every screen: design tokens (light and dark), resets and the small components the
 * screens have in common. theme.js sets <html data-theme>; light is also the fallback.
 * Screen-only styles live in login.css, desk.css and settings.css.
 */

/* Owner's choice: no visible scrollbars; scrolling still works. */
*,
*::before,
*::after {
  scrollbar-width: none;
}

::-webkit-scrollbar {
  display: none;
}

:root,
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f2f2f5;
  --card: #ffffff;
  --well: #ffffff;
  --chip: rgba(0, 0, 0, 0.06);
  --hover: rgba(0, 0, 0, 0.09);
  --line: rgba(0, 0, 0, 0.08);
  --ink: #1a1b1f;
  --ink-2: #5b5e68;
  --ink-3: #868995;
  --accent: #2f6fe0;
  --accent-ink: #2459b8;
  --accent-soft: rgba(47, 111, 224, 0.12);
  --accent-tint: rgba(47, 111, 224, 0.05);
  --danger: #c93a3f;
  --danger-ink: #b4262c;
  --danger-soft: rgba(201, 58, 63, 0.12);
  --warn-ink: #8a5000;
  --warn-soft: rgba(201, 138, 0, 0.16);
  --primary-bg: #1a1b1f;
  --primary-ink: #ffffff;
  --dot: rgba(0, 0, 0, 0.09);
  --doc: #ffffff;
  --fold: #dcdde3;
  --sel-tile: rgba(0, 0, 0, 0.07);
  --shadow-card: 0 6px 20px rgba(20, 22, 30, 0.08);
  --shadow-pop: 0 16px 36px rgba(20, 22, 30, 0.16);
  --ring-track: rgba(0, 0, 0, 0.12);
  --scrim: rgba(14, 15, 18, 0.36);
  --seg-other: #4a4d57;
  --seg-files: #2f6fe0;
  --seg-held: #7c9dd8;
  --seg-free: #e4e5ea;
  --bar-past: #868995;
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0e0f12;
  --card: #1a1b20;
  --well: rgba(255, 255, 255, 0.05);
  --chip: rgba(255, 255, 255, 0.08);
  --hover: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.1);
  --ink: #eef0f4;
  --ink-2: #b1b5c0;
  --ink-3: #8a8f9c;
  --accent: #5b9bff;
  --accent-ink: #a9cbff;
  --accent-soft: rgba(91, 155, 255, 0.18);
  --accent-tint: rgba(91, 155, 255, 0.07);
  --danger: #ff6b5e;
  --danger-ink: #ffb3aa;
  --danger-soft: rgba(255, 107, 94, 0.16);
  --warn-ink: #f2c14e;
  --warn-soft: rgba(242, 193, 78, 0.16);
  --primary-bg: #e6e7eb;
  --primary-ink: #121214;
  --dot: rgba(255, 255, 255, 0.07);
  --doc: #2a2c33;
  --fold: #3e414b;
  --sel-tile: rgba(255, 255, 255, 0.1);
  --shadow-card: 0 10px 28px rgba(0, 0, 0, 0.4);
  --shadow-pop: 0 18px 40px rgba(0, 0, 0, 0.6);
  --ring-track: rgba(255, 255, 255, 0.16);
  --scrim: rgba(0, 0, 0, 0.55);
  --seg-other: #c9ccd4;
  --seg-files: #5b9bff;
  --seg-held: #4470ba;
  --seg-free: #24262c;
  --bar-past: #8a8f9c;
}

/* ───────────── resets ───────────── */

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  /* Korean wraps between words, not inside them. */
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  color: var(--accent-ink);
  text-decoration: none;
}

a:hover {
  color: var(--ink);
}

button {
  cursor: pointer;
  font-family: inherit;
}

input {
  font-family: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ───────────── chips ───────────── */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.chip-accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.chip-warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

/* ───────────── pills (round buttons and button-like links) ───────────── */

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

a.pill,
a.pill:hover {
  color: var(--ink);
}

.pill:hover {
  background: var(--hover);
}

.pill-primary,
a.pill-primary,
a.pill-primary:hover {
  background: var(--primary-bg);
  color: var(--primary-ink);
}

.pill-primary:hover {
  background: var(--primary-bg);
  opacity: 0.9;
}

.pill-line {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--line);
}

.pill-line:hover {
  background: var(--chip);
}

.pill-danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.pill-danger:hover {
  background: var(--danger-soft);
  color: var(--danger-ink);
  opacity: 0.85;
}

.pill-sm {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
}

.pill:disabled,
.pill[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* A quiet button that reads as a link. */
.text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--accent-ink);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.text-btn:hover {
  background: var(--chip);
  color: var(--ink);
}

/* A round button with only an icon: give it an aria-label. */
.icon-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
}

.icon-btn:hover {
  background: var(--chip);
  color: var(--ink);
}

a.icon-btn {
  color: var(--ink);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

/* ───────────── text field in a pill (password and the like) ───────────── */

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink-2);
  box-shadow: inset 0 0 0 1.5px transparent;
}

.field:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.field.invalid {
  box-shadow: inset 0 0 0 1.5px var(--danger);
}

.field input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  outline: none;
}

/* The field's own ring shows focus. */
.field input:focus-visible {
  outline: none;
}

.field input[type='password'] {
  letter-spacing: 0.12em;
}

/* ───────────── alerts ───────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
}

.alert > svg {
  flex: none;
  margin-top: 2px;
}

.alert.danger {
  background: var(--danger-soft);
  color: var(--danger-ink);
}

.alert.warn {
  background: var(--warn-soft);
  color: var(--warn-ink);
}

.alert.info {
  align-items: center;
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.alert.ok {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* Title and text stacked inside an alert. */
.alert-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.alert-body strong {
  font-weight: 700;
}

.spin {
  flex: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spin {
    animation-duration: 2.4s;
  }
}

/* ───────────── toast (app.js shows it through ctx.toast) ───────────── */

.toast {
  position: fixed;
  left: 50%;
  top: 72px;
  z-index: 40;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--primary-bg);
  color: var(--primary-ink);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  pointer-events: none;
}
