/* H3 Studio — dependency-free, system-font UI */
:root {
  color-scheme: light;
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --canvas: #f4f5f0;
  --canvas-soft: #eef0e9;
  --surface: rgba(255, 255, 252, 0.84);
  --surface-solid: #fffffc;
  --surface-raised: #ffffff;
  --surface-muted: #f0f2ec;
  --surface-hover: #e9ece4;
  --ink: #181b19;
  --ink-secondary: #575e59;
  --ink-tertiary: #7d857f;
  --line: rgba(26, 32, 28, 0.11);
  --line-strong: rgba(26, 32, 28, 0.2);
  --accent: #206e4d;
  --accent-strong: #145a3c;
  --accent-soft: #dff2e7;
  --accent-ink: #0d5033;
  --warning: #a75d14;
  --warning-soft: #fff0d9;
  --danger: #b73b39;
  --danger-strong: #982b2a;
  --danger-soft: #fde8e6;
  --info: #3567aa;
  --info-soft: #e6eefb;
  --shadow-sm: 0 1px 2px rgba(12, 18, 14, 0.04), 0 8px 24px rgba(12, 18, 14, 0.035);
  --shadow-md: 0 18px 55px rgba(18, 28, 22, 0.09), 0 2px 8px rgba(18, 28, 22, 0.05);
  --radius-sm: 10px;
  --radius-md: 15px;
  --radius-lg: 22px;
  --sidebar-width: 248px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0c0e0d;
  --canvas-soft: #101311;
  --surface: rgba(19, 23, 20, 0.86);
  --surface-solid: #131714;
  --surface-raised: #181c19;
  --surface-muted: #1a1f1b;
  --surface-hover: #222822;
  --ink: #f1f3ee;
  --ink-secondary: #adb5ae;
  --ink-tertiary: #7e8980;
  --line: rgba(232, 240, 234, 0.1);
  --line-strong: rgba(232, 240, 234, 0.18);
  --accent: #75d3a4;
  --accent-strong: #94e0b8;
  --accent-soft: #173a2a;
  --accent-ink: #a6eac5;
  --warning: #edaa62;
  --warning-soft: #3a2918;
  --danger: #f0807d;
  --danger-strong: #ff9a96;
  --danger-soft: #3f201f;
  --info: #86afe5;
  --info-soft: #1d2e45;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 22px 60px rgba(0, 0, 0, 0.34), 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0c0e0d;
    --canvas-soft: #101311;
    --surface: rgba(19, 23, 20, 0.86);
    --surface-solid: #131714;
    --surface-raised: #181c19;
    --surface-muted: #1a1f1b;
    --surface-hover: #222822;
    --ink: #f1f3ee;
    --ink-secondary: #adb5ae;
    --ink-tertiary: #7e8980;
    --line: rgba(232, 240, 234, 0.1);
    --line-strong: rgba(232, 240, 234, 0.18);
    --accent: #75d3a4;
    --accent-strong: #94e0b8;
    --accent-soft: #173a2a;
    --accent-ink: #a6eac5;
    --warning: #edaa62;
    --warning-soft: #3a2918;
    --danger: #f0807d;
    --danger-strong: #ff9a96;
    --danger-soft: #3f201f;
    --info: #86afe5;
    --info-soft: #1d2e45;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 22px 60px rgba(0, 0, 0, 0.34), 0 2px 8px rgba(0, 0, 0, 0.2);
  }
}

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

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--canvas);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.dropzone.is-disabled {
  cursor: not-allowed;
  opacity: 0.58;
  pointer-events: none;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
}

::selection {
  background: var(--accent);
  color: var(--surface-solid);
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 9px 13px;
  transform: translateY(-160%);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--surface-solid);
  font-weight: 650;
  transition: transform 160ms var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-background {
  position: fixed;
  z-index: -1;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(3px);
  opacity: 0.64;
}

.ambient-a {
  top: -260px;
  right: -170px;
  width: 620px;
  height: 620px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 10%, transparent), transparent 66%);
}

.ambient-b {
  bottom: -300px;
  left: 12%;
  width: 660px;
  height: 660px;
  background: radial-gradient(circle, color-mix(in srgb, var(--info) 7%, transparent), transparent 67%);
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  z-index: 20;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: var(--sidebar-width);
  padding: 24px 18px 20px;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

.brand {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  fill: color-mix(in srgb, var(--accent) 11%, transparent);
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.brand-mark path + path {
  fill: none;
  stroke-width: 2;
}

.brand-name {
  font-size: 16px;
  font-weight: 760;
  letter-spacing: -0.02em;
}

.brand-name span {
  color: var(--ink-secondary);
  font-weight: 560;
}

.nav-list {
  display: grid;
  gap: 5px;
  margin-top: 35px;
}

.nav-item {
  display: flex;
  min-height: 45px;
  padding: 0 13px;
  align-items: center;
  gap: 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 610;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.nav-item svg,
.mobile-nav-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.nav-item.is-active {
  border-color: color-mix(in srgb, var(--accent) 18%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.nav-count {
  min-width: 22px;
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 11%, transparent);
  font-size: 11px;
  text-align: center;
}

.sidebar-spacer {
  flex: 1;
}

.system-summary {
  display: flex;
  min-width: 0;
  padding: 12px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.status-dot {
  position: relative;
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--ink-tertiary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink-tertiary) 12%, transparent);
}

.status-dot.is-ok {
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}

.status-dot.is-warning {
  background: var(--warning);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 14%, transparent);
}

.status-dot.is-danger {
  background: var(--danger);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 14%, transparent);
}

.system-summary-copy {
  display: grid;
  min-width: 0;
  line-height: 1.28;
}

.system-summary-copy strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-summary-copy small {
  overflow: hidden;
  color: var(--ink-tertiary);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-footer {
  display: flex;
  min-height: 50px;
  padding: 10px 4px 0;
  align-items: center;
  justify-content: space-between;
}

.logout-button {
  display: inline-flex;
  min-height: 38px;
  padding: 0 10px;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 620;
}

.logout-button:hover {
  border-color: var(--line);
  background: var(--surface-muted);
  color: var(--ink);
}

.logout-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: transparent;
  color: var(--ink-secondary);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-muted);
  color: var(--ink);
}

.theme-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.theme-icon-moon,
:root[data-theme="dark"] .theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-icon-moon { display: block; }
}

.mobile-header,
.mobile-nav {
  display: none;
}

.main-content {
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: var(--sidebar-width);
  padding: 46px clamp(32px, 5vw, 80px) 80px;
}

.route-loading {
  display: flex;
  min-height: 65vh;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--ink-tertiary);
  font-size: 13px;
}

.loading-mark,
.button-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

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

.page {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  animation: page-in 380ms var(--ease-out) both;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-narrow {
  max-width: 920px;
}

.page-header {
  display: flex;
  min-height: 72px;
  margin-bottom: 30px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.page-eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-title {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  font-weight: 690;
  letter-spacing: -0.045em;
  line-height: 1.1;
}

.page-description {
  max-width: 620px;
  margin: 10px 0 0;
  color: var(--ink-secondary);
  font-size: 14px;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 43px;
  padding: 0 17px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 670;
  line-height: 1;
  transition: transform 150ms var(--ease-out), background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.button-primary {
  background: var(--accent-strong);
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--surface-solid);
}

:root[data-theme="dark"] .button-primary {
  background: var(--accent);
  color: #092317;
}

.button-primary:hover:not(:disabled) {
  box-shadow: 0 9px 24px color-mix(in srgb, var(--accent) 25%, transparent);
}

.button-secondary {
  border-color: var(--line);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-solid);
}

.button-quiet {
  background: transparent;
  color: var(--ink-secondary);
}

.button-quiet:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--ink);
}

.button-danger {
  background: var(--danger-strong);
  color: #fff;
}

.button-danger-quiet {
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.generation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  gap: 20px;
  align-items: start;
}

.generation-form-card {
  padding: clamp(22px, 4vw, 38px);
}

.form-section + .form-section {
  margin-top: 31px;
  padding-top: 29px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  margin-bottom: 15px;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 690;
  letter-spacing: -0.015em;
}

.section-hint {
  color: var(--ink-tertiary);
  font-size: 11px;
}

.field {
  display: grid;
  gap: 8px;
}

.field + .field {
  margin-top: 18px;
}

.field-label {
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 650;
}

.required-mark {
  color: var(--danger);
}

.field-help {
  margin: 0;
  color: var(--ink-tertiary);
  font-size: 11px;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  outline: none;
  background: var(--surface-solid);
  color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.text-input,
.select-input {
  height: 44px;
  padding: 0 13px;
}

.select-input {
  padding-right: 36px;
}

.textarea-input {
  min-height: 156px;
  padding: 14px 15px;
  line-height: 1.65;
  resize: vertical;
}

.text-input:hover,
.select-input:hover,
.textarea-input:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong));
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.textarea-meta {
  display: flex;
  margin-top: -2px;
  justify-content: space-between;
  color: var(--ink-tertiary);
  font-size: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

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

.dropzone {
  position: relative;
  display: grid;
  min-height: 132px;
  padding: 24px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-muted) 60%, transparent);
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease, transform 150ms var(--ease-out);
}

.dropzone:hover,
.dropzone.is-dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.is-dragging {
  transform: scale(1.005);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.dropzone-copy {
  display: grid;
  place-items: center;
}

.dropzone-icon {
  display: grid;
  width: 38px;
  height: 38px;
  margin-bottom: 10px;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
  color: var(--accent);
}

.dropzone-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.dropzone strong {
  font-size: 13px;
  font-weight: 670;
}

.dropzone span {
  margin-top: 3px;
  color: var(--ink-tertiary);
  font-size: 11px;
}

.attachment-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.attachment-item {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) minmax(140px, 190px) 34px;
  min-height: 58px;
  padding: 8px 10px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
}

.file-kind {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
}

.file-kind svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.file-copy {
  min-width: 0;
  line-height: 1.35;
}

.file-copy strong {
  display: block;
  overflow: hidden;
  font-size: 12px;
  font-weight: 630;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy small {
  color: var(--ink-tertiary);
  font-size: 10px;
}

.attachment-item .select-input {
  height: 36px;
  font-size: 11px;
}

.remove-attachment {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-tertiary);
}

.remove-attachment:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.remove-attachment svg {
  width: 16px;
  height: 16px;
  margin: auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.form-error {
  display: flex;
  margin-top: 18px;
  padding: 11px 13px;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
  border-radius: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12px;
}

.form-error svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.form-actions {
  display: flex;
  margin-top: 27px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.submit-note {
  max-width: 340px;
  margin: 0;
  color: var(--ink-tertiary);
  font-size: 10px;
}

.button-spinner {
  width: 14px;
  height: 14px;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
}

.generation-aside {
  display: grid;
  gap: 12px;
}

.aside-card {
  padding: 18px;
}

.aside-card h3 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 680;
}

.route-preview {
  display: grid;
  gap: 11px;
}

.route-row {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 10px;
}

.route-number {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 9px;
}

.route-row strong {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 650;
}

.route-row small {
  color: var(--ink-tertiary);
  font-size: 10px;
}

.privacy-note {
  display: flex;
  gap: 10px;
  color: var(--ink-secondary);
  font-size: 10px;
}

.privacy-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.toolbar {
  display: flex;
  margin-bottom: 17px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.segmented-control {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-muted);
}

.segment-button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 620;
}

.segment-button.is-active {
  background: var(--surface-raised);
  box-shadow: 0 1px 4px rgba(10, 20, 13, 0.07);
  color: var(--ink);
}

.search-wrap {
  position: relative;
  width: min(280px, 100%);
}

.search-wrap svg {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--ink-tertiary);
  stroke-linecap: round;
  stroke-width: 1.7;
}

.search-wrap .text-input {
  height: 39px;
  padding-left: 37px;
  font-size: 12px;
}

.jobs-card {
  overflow: hidden;
}

.job-list-header,
.job-row {
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) minmax(110px, .65fr) minmax(120px, .7fr) minmax(120px, .7fr) 28px;
  align-items: center;
  gap: 18px;
}

.job-list-header {
  min-height: 43px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-tertiary);
  font-size: 9px;
  font-weight: 660;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.job-row {
  min-height: 78px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  transition: background 150ms ease;
}

.job-row:last-child {
  border-bottom: 0;
}

.job-row:hover {
  background: color-mix(in srgb, var(--surface-muted) 65%, transparent);
}

.job-primary {
  min-width: 0;
}

.job-prompt {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 630;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-id {
  color: var(--ink-tertiary);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.status-badge {
  display: inline-flex;
  width: max-content;
  max-width: 100%;
  min-height: 26px;
  padding: 0 9px;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.status-badge::before {
  width: 5px;
  height: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-badge.is-active,
.status-badge.is-success {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.status-badge.is-waiting {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge.is-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge.is-canceled {
  color: var(--ink-tertiary);
}

.job-meta {
  color: var(--ink-secondary);
  font-size: 11px;
}

.job-meta small {
  display: block;
  color: var(--ink-tertiary);
  font-size: 9px;
}

.row-chevron {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: var(--ink-tertiary);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.empty-state,
.error-state {
  display: grid;
  min-height: 360px;
  padding: 50px 24px;
  place-items: center;
  text-align: center;
}

.state-content {
  max-width: 390px;
}

.state-illustration {
  position: relative;
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto 18px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-muted);
  color: var(--ink-secondary);
}

.state-illustration svg {
  width: 27px;
  height: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.state-content h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
}

.state-content p {
  margin: 7px 0 20px;
  color: var(--ink-secondary);
  font-size: 12px;
}

.skeleton-list {
  overflow: hidden;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 1.6fr .7fr .7fr .7fr;
  min-height: 78px;
  padding: 20px;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}

.skeleton-row:last-child { border-bottom: 0; }

.skeleton-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--surface-muted), var(--surface-hover), var(--surface-muted));
  background-size: 220% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer { to { background-position: -220% 0; } }

.detail-header {
  align-items: center;
}

.back-link {
  display: inline-flex;
  margin-bottom: 12px;
  align-items: center;
  gap: 6px;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 620;
}

.back-link:hover { color: var(--ink); }

.back-link svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.detail-title-row .page-title {
  font-family: var(--font-mono);
  font-size: clamp(19px, 3vw, 27px);
  font-weight: 620;
  letter-spacing: -0.025em;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, .75fr);
  gap: 18px;
  align-items: start;
}

.detail-main,
.detail-aside {
  display: grid;
  gap: 18px;
}

.progress-card {
  padding: clamp(24px, 4vw, 38px);
}

.progress-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.progress-phase {
  margin: 0 0 3px;
  color: var(--ink-tertiary);
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.progress-message {
  margin: 0;
  font-size: clamp(19px, 3vw, 25px);
  font-weight: 660;
  letter-spacing: -0.025em;
}

.progress-number {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 560;
  letter-spacing: -0.06em;
}

.progress-number small {
  color: var(--ink-tertiary);
  font-size: 13px;
  letter-spacing: 0;
}

.progress-track {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 26px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 999px;
  background: var(--surface-muted);
}

.progress-track::-webkit-progress-bar {
  border-radius: inherit;
  background: var(--surface-muted);
}

.progress-track::-webkit-progress-value {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
}

.progress-track::-moz-progress-bar {
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
}

.progress-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 22px;
  gap: 12px;
}

.progress-fact {
  min-width: 0;
}

.progress-fact span {
  display: block;
  margin-bottom: 2px;
  color: var(--ink-tertiary);
  font-size: 9px;
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.progress-fact strong {
  display: block;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 570;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-notice,
.error-notice,
.success-notice,
.cancel-notice {
  display: flex;
  margin-top: 22px;
  padding: 13px 14px;
  align-items: flex-start;
  gap: 10px;
  border-radius: 12px;
  font-size: 11px;
}

.queue-notice {
  border: 1px solid color-mix(in srgb, var(--warning) 23%, transparent);
  background: var(--warning-soft);
  color: var(--warning);
}

.error-notice {
  border: 1px solid color-mix(in srgb, var(--danger) 23%, transparent);
  background: var(--danger-soft);
  color: var(--danger);
}

.success-notice {
  border: 1px solid color-mix(in srgb, var(--accent) 20%, transparent);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.cancel-notice {
  border: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--ink-secondary);
}

.queue-notice svg,
.error-notice svg,
.success-notice svg,
.cancel-notice svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.notice-copy strong { display: block; margin-bottom: 2px; font-size: 11px; }
.notice-copy span { color: color-mix(in srgb, currentColor 80%, var(--ink)); }

.prompt-card,
.metadata-card {
  padding: 23px;
}

.card-title {
  margin: 0 0 15px;
  color: var(--ink-tertiary);
  font-size: 9px;
  font-weight: 680;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.prompt-text {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.expanded-prompt {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.expanded-prompt summary {
  color: var(--ink-tertiary);
  cursor: pointer;
  font-size: 11px;
  font-weight: 620;
}

.expanded-prompt .prompt-text { margin-top: 12px; font-size: 11px; }

.metadata-list {
  margin: 0;
}

.metadata-row {
  display: flex;
  min-height: 38px;
  padding: 9px 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--line);
}

.metadata-row:last-child { border-bottom: 0; }

.metadata-row dt {
  color: var(--ink-tertiary);
  font-size: 10px;
}

.metadata-row dd {
  max-width: 65%;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: right;
}

.system-card {
  padding: 18px;
}

.system-card-header {
  display: flex;
  margin-bottom: 13px;
  align-items: center;
  justify-content: space-between;
}

.system-card-header h3 {
  margin: 0;
  font-size: 12px;
}

.system-lines {
  display: grid;
  gap: 9px;
}

.system-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink-tertiary);
  font-size: 10px;
}

.system-line strong {
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  font-weight: 570;
}

.quota-track {
  display: block;
  width: 100%;
  height: 5px;
  margin-top: 5px;
  overflow: hidden;
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: 99px;
  background: var(--surface-muted);
}

.quota-track::-webkit-progress-bar {
  border-radius: inherit;
  background: var(--surface-muted);
}

.quota-track::-webkit-progress-value,
.quota-track::-moz-progress-bar {
  border-radius: inherit;
  background: var(--accent);
}

.skeleton-w-65 { width: 65%; }
.skeleton-w-48 { width: 48%; }
.skeleton-w-42 { width: 42%; }
.skeleton-w-36 { width: 36%; }

.login-shell {
  display: grid;
  min-height: calc(100vh - 92px);
  min-height: calc(100dvh - 92px);
  place-items: center;
}

.login-panel {
  display: grid;
  width: min(100%, 430px);
  padding: clamp(26px, 6vw, 42px);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.login-brand {
  display: grid;
  margin-bottom: 32px;
  place-items: center;
  text-align: center;
}

.login-brand .brand-mark {
  width: 50px;
  height: 50px;
  margin-bottom: 15px;
}

.login-brand h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.login-brand p {
  margin: 7px 0 0;
  color: var(--ink-secondary);
  font-size: 12px;
}

.password-wrap { position: relative; }
.password-wrap .text-input { padding-right: 45px; }

.password-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-tertiary);
}

.password-toggle:hover { background: var(--surface-muted); color: var(--ink); }

.password-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.login-panel .button-primary {
  width: 100%;
  margin-top: 21px;
}

.login-security {
  display: flex;
  margin: 24px 0 0;
  padding-top: 20px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-top: 1px solid var(--line);
  color: var(--ink-tertiary);
  font-size: 9px;
}

.login-security svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

body.is-login .sidebar,
body.is-login .mobile-nav {
  display: none;
}

body.is-login .main-content {
  width: 100%;
  margin-left: 0;
}

body.is-login .mobile-header {
  display: none;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  padding: 13px 14px;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--ink-secondary);
  font-size: 11px;
  pointer-events: auto;
  animation: toast-in 280ms var(--ease-out) both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast.is-leaving { animation: toast-out 180ms ease both; }
@keyframes toast-out { to { opacity: 0; transform: translateY(5px); } }

.toast-icon {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent);
}

.toast.is-error .toast-icon { background: var(--danger); }
.toast strong { display: block; margin-bottom: 1px; color: var(--ink); font-size: 11px; }

.confirm-dialog {
  width: min(410px, calc(100vw - 30px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 21px;
  background: var(--surface-raised);
  box-shadow: var(--shadow-md);
  color: var(--ink);
}

.confirm-dialog::backdrop {
  background: rgba(7, 10, 8, 0.56);
  backdrop-filter: blur(4px);
}

.confirm-dialog form { padding: 27px; }

.dialog-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 17px;
  place-items: center;
  border-radius: 12px;
  background: var(--warning-soft);
  color: var(--warning);
}

.dialog-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.6;
}

.confirm-dialog h2 { margin: 0; font-size: 18px; }
.confirm-dialog p { margin: 8px 0 24px; color: var(--ink-secondary); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.noscript-message {
  position: fixed;
  z-index: 1000;
  inset: auto 16px 16px;
  padding: 13px;
  border-radius: 12px;
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
}

@media (max-width: 980px) {
  .generation-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .generation-aside {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-aside {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .job-list-header,
  .job-row {
    grid-template-columns: minmax(220px, 1.5fr) minmax(110px, .7fr) minmax(100px, .7fr) 24px;
  }

  .job-list-header > :nth-child(4),
  .job-row > :nth-child(4) { display: none; }
}

@media (max-width: 760px) {
  :root { --mobile-nav-height: 70px; }

  .sidebar { display: none; }

  .mobile-header {
    position: fixed;
    z-index: 20;
    top: 0;
    right: 0;
    left: 0;
    display: flex;
    height: 64px;
    padding: 8px 17px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 80%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  .mobile-header .brand-mark { width: 31px; height: 31px; }
  .mobile-header-actions { display: flex; align-items: center; gap: 14px; }

  .mobile-nav {
    position: fixed;
    z-index: 20;
    right: 12px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 12px;
    display: grid;
    height: 59px;
    padding: 5px;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    border: 1px solid var(--line-strong);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-raised) 91%, transparent);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(22px);
    -webkit-backdrop-filter: blur(22px);
  }

  .mobile-nav-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 13px;
    color: var(--ink-tertiary);
    font-size: 10px;
    font-weight: 650;
  }

  .mobile-nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent-ink);
  }

  .main-content {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    margin-left: 0;
    padding: 94px 16px calc(var(--mobile-nav-height) + 28px + env(safe-area-inset-bottom));
  }

  .page-header { margin-bottom: 23px; }
  .page-title { font-size: 30px; }
  .generation-form-card { padding: 21px 17px; }
  .generation-aside, .detail-aside { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .field:last-child { grid-column: 1 / -1; }
  .attachment-item { grid-template-columns: 34px minmax(0, 1fr) 34px; }
  .attachment-item .select-input { grid-column: 1 / -1; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .submit-note { max-width: none; text-align: center; }

  .toolbar { align-items: stretch; flex-direction: column; }
  .segmented-control { align-self: flex-start; }
  .search-wrap { width: 100%; }

  .job-list-header { display: none; }
  .job-row {
    grid-template-columns: minmax(0, 1fr) auto 18px;
    min-height: 90px;
    padding: 15px;
    gap: 10px;
  }
  .job-row > :nth-child(3),
  .job-row > :nth-child(4) { display: none; }
  .job-prompt { max-width: 58vw; }

  .detail-header { align-items: flex-start; }
  .detail-header .header-actions { width: 100%; }
  .detail-header .header-actions .button { flex: 1; }
  .progress-card { padding: 22px 18px; }
  .progress-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-fact:last-child { grid-column: 1 / -1; }

  body.is-login .main-content { padding: 20px 16px; }
  .login-shell { min-height: calc(100vh - 40px); min-height: calc(100dvh - 40px); }
  .login-panel { border-radius: 21px; }

  .toast-region { right: 16px; bottom: calc(82px + env(safe-area-inset-bottom)); }
}

@media (max-width: 520px) {
  .page-header { align-items: stretch; flex-direction: column; }
  .page-header:not(.detail-header) .header-actions { width: 100%; }
  .page-header:not(.detail-header) .header-actions .button { flex: 1; }
  .form-grid, .advanced-grid { grid-template-columns: 1fr; }
  .form-grid .field:last-child { grid-column: auto; }
  .progress-heading { gap: 12px; }
  .progress-number { font-size: 22px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
