﻿/* =================================================================
   FreeSum Base Styles v2 — reset, typography, components
   ================================================================= */

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

html {
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(79,140,255,.10), transparent 60%),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

html[data-theme="light"] body {
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(37,99,235,.08), transparent 60%),
    linear-gradient(180deg, #f0f2f6 0%, #f5f6f8 100%);
}

img, svg, video { display: block; max-width: 100%; }

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: 22px; font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-2); }
h3 { font-size: 15px; font-weight: 600; }
p  { margin: 0; }

code, kbd, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

kbd {
  display: inline-block;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 11px;
  color: var(--text-1);
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 9999;
}
.skip-link:focus { left: 0; }

/* ---------- Focus rings ---------- */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- Selection ---------- */
::selection {
  background: var(--accent-soft);
  color: var(--text-1);
}

/* ---------- Scrollbars ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--border-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-3); border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--bg-5); background-clip: padding-box; border: 2px solid transparent; }

/* ---------- Layout ---------- */
.wrap {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 24px 80px;
}
@media (max-width: 720px) {
  .wrap { padding: 16px 12px 100px; }
  h1 { font-size: 18px; }
}

/* ---------- Header ---------- */
header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  animation: fadeInUp .5s var(--ease-out) both;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--warm));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.2);
  position: relative;
  overflow: hidden;
}
.brand .logo::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.25), transparent 50%);
  pointer-events: none;
}
.brand h1 { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.brand h1 .accent { color: var(--accent); }
.brand h1 .ver { color: var(--text-3); font-weight: 400; font-size: 13px; font-family: var(--font-mono); }
.brand .sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }

.nav-group { display: flex; gap: 6px; }
.nav-link, button.nav-link {
  background: var(--bg-2);
  color: var(--text-1);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.nav-link:hover, button.nav-link:hover {
  background: var(--bg-3);
  border-color: var(--border-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.nav-link:active, button.nav-link:active { transform: translateY(0); }
.nav-link .ic { font-size: 14px; line-height: 1; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-lg);
  padding: 0;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
  animation: fadeInUp .5s var(--ease-out) both;
}
.card:nth-of-type(1) { animation-delay: 60ms; }
.card:nth-of-type(2) { animation-delay: 120ms; }
.card:nth-of-type(3) { animation-delay: 180ms; }

.card-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, var(--bg-3) 0%, transparent 100%);
}
.card-head h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px;
}
.card-head h2 .ic { color: var(--accent); font-size: 16px; }
.card-head .head-meta {
  color: var(--text-3);
  font-size: 12px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  display: flex; gap: 12px; align-items: center;
}
.card-body { padding: 20px; min-width: 0; }

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .35; }
}
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes readyPulse {
  0%,100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50%     { box-shadow: 0 0 0 10px transparent; }
}

/* ---------- Buttons ---------- */
button {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  transition: background var(--t-fast), border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
button:hover:not(:disabled) { background: var(--bg-4); border-color: var(--border-3); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button:focus-visible { box-shadow: var(--shadow-focus); border-color: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

button.danger {
  background: transparent;
  border-color: var(--error-soft);
  color: var(--error);
}
button.danger:hover:not(:disabled) { background: var(--error-soft); border-color: var(--error); }

button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
button.ghost:hover:not(:disabled) { background: var(--bg-3); color: var(--text-1); }

/* ---------- Forms ---------- */
input[type=text], input[type=number], input[type=password], input[type=email], select, textarea {
  width: 100%;
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font: inherit;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-2);
}
input[type=color] {
  width: 40px; height: 40px;
  padding: 0;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  background: var(--bg-3);
  cursor: pointer;
}
input[type=checkbox], input[type=radio] {
  accent-color: var(--accent);
  width: 16px; height: 16px;
  cursor: pointer;
  vertical-align: middle;
}
input[type=range] { accent-color: var(--accent); cursor: pointer; }

label { font-size: 12px; color: var(--text-2); display: block; margin-bottom: 6px; font-weight: 500; }
label.help { color: var(--text-3); font-weight: 400; font-size: 11px; margin-top: 4px; }

.help { font-size: 11px; color: var(--text-3); margin-top: 4px; line-height: 1.45; }

/* ---------- Pills / Badges ---------- */
.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.pill.idle       { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border-1); }
.pill.merging,
.pill.subtitling { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-glow); }
.pill.merging::before, .pill.subtitling::before {
  content: "●"; display: inline-block;
  margin-right: 5px;
  animation: pulse 1.4s ease-in-out infinite;
}
.pill.merged,
.pill.done       { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.pill.cancelled  { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.pill.error      { background: var(--error-soft); color: var(--error); border: 1px solid var(--error); }

/* ---------- Progress ---------- */
.progress {
  height: 8px;
  background: var(--bg-3);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-1);
  position: relative;
}
.progress > div {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
  transition: width .3s var(--ease);
  border-radius: 999px;
}
.progress.done > div {
  background: var(--success);
  animation: none;
}
.progress.err > div {
  background: var(--error);
  animation: none;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn .2s var(--ease-out);
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 22px;
  max-width: 760px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalUp .35s var(--ease-out);
}
@keyframes modalUp {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: none;
  letter-spacing: -0.01em;
  color: var(--text-1);
  display: flex; align-items: center; gap: 10px;
}
.modal-close {
  float: right;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 6px 8px;
  border-radius: 6px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-1); background: var(--bg-3); border-color: var(--border-1); }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1100;
  pointer-events: none;
}
.toast {
  background: var(--bg-2);
  color: var(--text-1);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s var(--ease-out);
  pointer-events: auto;
  max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--error); }
.toast.warn    { border-left: 3px solid var(--warn); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Utility ---------- */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row + .row { margin-top: 14px; }
.field { flex: 1 1 180px; min-width: 140px; }
.field.small { flex: 0 0 110px; }
.field.full  { flex: 1 1 100%; }
.flex { display: flex; }
.between { display: flex; justify-content: space-between; align-items: center; }
.center  { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.dim { color: var(--text-3); }
.mono-text { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- Footer ---------- */
.footer {
  color: var(--text-3);
  font-size: 11px;
  margin-top: 20px;
  text-align: center;
  font-family: var(--font-mono);
}
.footer code {
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  padding: 2px 7px;
  border-radius: 4px;
  color: var(--text-2);
}