:root {
  --bg: #f4f5f2;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #ffffff;
  --ink: #17201d;
  --muted: #65706c;
  --line: rgba(23, 32, 29, 0.11);
  --primary: #146c54;
  --primary-dark: #0c4d3b;
  --primary-soft: #dcefe8;
  --accent: #e89438;
  --danger: #b43f4b;
  --danger-soft: #fbe6e8;
  --shadow: 0 22px 60px rgba(32, 51, 44, 0.09);
  --radius: 24px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.sso-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(8, 15, 30, 0.72);
  backdrop-filter: blur(14px);
}

.sso-gate[hidden] {
  display: none;
}

.sso-card {
  width: min(420px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: center;
}

.sso-card .brand-mark {
  margin: 0 auto 18px;
}

.sso-card h1 {
  margin: 0 0 12px;
}

.sso-card p {
  min-height: 48px;
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.6;
}

.sso-card a {
  display: inline-flex;
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  text-decoration: none;
}

.sso-gate.error .sso-card {
  border-color: rgba(239, 68, 68, 0.45);
}

.auth-pending .shell {
  pointer-events: none;
  user-select: none;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 460px;
  height: 460px;
  border-radius: 50%;
  filter: blur(100px);
  opacity: .34;
}

.ambient-one { top: -180px; right: -100px; background: #98d7bf; }
.ambient-two { bottom: -260px; left: -140px; background: #f3c78f; }

.shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 36px;
}

.topbar,
.brand,
.section-heading,
.tasks-heading,
.form-footer,
.task-top,
.task-meta,
.task-actions,
.connection {
  display: flex;
  align-items: center;
}

.topbar { justify-content: space-between; margin-bottom: 28px; }
.brand { gap: 13px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  background: var(--primary);
  border-radius: 15px 15px 15px 5px;
  box-shadow: 0 10px 26px rgba(20, 108, 84, .24);
}

h1, h2, h3, p { margin-top: 0; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.connection {
  gap: 8px;
  padding: 9px 13px;
  color: var(--primary-dark);
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.connection-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.connection.ready .connection-dot { background: #2aa873; box-shadow: 0 0 0 4px rgba(42,168,115,.12); }
.connection.error .connection-dot { background: var(--danger); }

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.create-panel { padding: 28px; }
.config-panel { padding: 26px; }
.section-heading { justify-content: space-between; margin-bottom: 24px; }
.section-heading.compact { margin-bottom: 22px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--primary); font-size: 10px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.section-heading h2, .tasks-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.step { color: rgba(23,32,29,.14); font-size: 31px; font-weight: 800; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin: 0 0 8px 2px; color: #43504b; font-size: 12px; font-weight: 700; }

input, textarea {
  width: 100%;
  padding: 13px 15px;
  color: var(--ink);
  background: rgba(247,249,247,.9);
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

textarea { resize: vertical; min-height: 88px; line-height: 1.5; }
input:focus, textarea:focus { background: #fff; border-color: rgba(20,108,84,.5); box-shadow: 0 0 0 4px rgba(20,108,84,.09); }
input::placeholder, textarea::placeholder { color: #9aa29f; }

.advanced { margin: 1px 0 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.advanced summary { padding: 14px 2px; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.advanced-content { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; padding-top: 5px; }
.advanced-content .field-wide, .privacy-note { grid-column: 1 / -1; }
.privacy-note { margin: -7px 2px 16px; color: var(--muted); font-size: 11px; line-height: 1.6; }

.form-footer { justify-content: space-between; gap: 20px; }
.form-footer p { max-width: 420px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }

.primary-button, .secondary-button, .task-button, .icon-button {
  border: 0;
  transition: transform .15s, opacity .15s, background .15s;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  min-width: 170px;
  padding: 14px 17px;
  color: #fff;
  background: var(--primary);
  border-radius: 13px;
  font-weight: 750;
}

.primary-button:hover { background: var(--primary-dark); transform: translateY(-1px); }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; }

.config-list { margin: 0 0 22px; }
.config-list > div { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.config-list dt { color: var(--muted); font-size: 12px; }
.config-list dd { margin: 0; font-size: 12px; font-weight: 700; overflow-wrap: anywhere; }

.secondary-button { width: 100%; padding: 12px 15px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 12px; font-size: 12px; font-weight: 750; }
.secondary-button:hover { background: #cce8de; }
.secondary-button:disabled { opacity: .55; cursor: wait; }
.test-result { min-height: 18px; margin: 10px 2px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.test-result.success { color: var(--primary); }
.test-result.error { color: var(--danger); }

.tasks-section { margin-top: 38px; }
.tasks-heading { justify-content: space-between; margin-bottom: 16px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; color: var(--primary-dark); background: rgba(255,255,255,.68); border: 1px solid var(--line); border-radius: 12px; font-size: 19px; }
.icon-button:hover { transform: rotate(25deg); }

.empty-state { padding: 56px 20px; text-align: center; background: rgba(255,255,255,.48); border: 1px dashed rgba(23,32,29,.18); border-radius: 20px; }
.empty-icon { margin-bottom: 8px; color: var(--primary); font-size: 34px; }
.empty-state h3 { margin-bottom: 8px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

.task-list { display: grid; gap: 12px; }
.task-card { padding: 19px 20px; background: var(--panel-strong); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 10px 32px rgba(32,51,44,.05); }
.task-top { justify-content: space-between; gap: 16px; }
.task-title { min-width: 0; }
.task-title h3 { margin: 0 0 5px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.task-source { margin: 0; color: var(--muted); font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status-badge { flex: none; padding: 6px 9px; color: var(--primary-dark); background: var(--primary-soft); border-radius: 999px; font-size: 10px; font-weight: 800; }
.status-badge.failed, .status-badge.canceled { color: var(--danger); background: var(--danger-soft); }
.status-badge.completed { color: #fff; background: var(--primary); }
.status-badge.queued { color: #825418; background: #fff0d9; }

.progress-track { height: 7px; margin: 18px 0 10px; overflow: hidden; background: #e9eeeb; border-radius: 999px; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), #34a57f); border-radius: inherit; transition: width .5s ease; }
.progress-track.indeterminate .progress-bar { width: 32%; animation: indeterminate 1.4s infinite ease-in-out; }
@keyframes indeterminate { from { transform: translateX(-110%); } to { transform: translateX(340%); } }

.task-meta { flex-wrap: wrap; gap: 7px 18px; color: var(--muted); font-size: 10px; }
.task-meta strong { color: var(--ink); font-weight: 750; }
.task-error { margin: 13px 0 0; padding: 10px 12px; color: #8e303a; background: var(--danger-soft); border-radius: 10px; font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.remote-path { margin: 13px 0 0; color: var(--primary-dark); font-size: 11px; font-weight: 700; overflow-wrap: anywhere; }
.task-actions { justify-content: flex-end; gap: 7px; margin-top: 14px; }
.task-button { padding: 8px 11px; color: #4b5652; background: #eef1ef; border-radius: 9px; font-size: 10px; font-weight: 750; }
.task-button:hover { color: var(--ink); background: #e1e7e3; }
.task-button.danger { color: var(--danger); background: var(--danger-soft); }

footer { display: flex; justify-content: space-between; margin-top: 30px; color: var(--muted); font-size: 10px; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: min(380px, calc(100vw - 48px)); padding: 13px 16px; color: #fff; background: #1e2925; border-radius: 12px; box-shadow: 0 15px 40px rgba(0,0,0,.2); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(12px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8e303a; }

@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .config-panel { order: -1; }
  .config-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
}

@media (max-width: 580px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 18px; }
  .topbar { align-items: flex-start; }
  .connection { max-width: 132px; text-align: right; }
  .brand p { display: none; }
  .create-panel, .config-panel { padding: 20px; border-radius: 20px; }
  .field-row, .advanced-content { grid-template-columns: 1fr; }
  .advanced-content .field-wide, .privacy-note { grid-column: auto; }
  .form-footer { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
  .config-list { grid-template-columns: 1fr; }
  .task-card { padding: 16px; }
  footer { flex-direction: column; gap: 5px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111714;
    --panel: rgba(25, 34, 30, .87);
    --panel-strong: #19211e;
    --ink: #eef5f1;
    --muted: #9ba9a3;
    --line: rgba(238,245,241,.11);
    --primary: #46b58c;
    --primary-dark: #8ed9bd;
    --primary-soft: #203d33;
    --danger-soft: #42262b;
    --shadow: 0 22px 60px rgba(0,0,0,.2);
  }
  input, textarea { background: rgba(12,18,15,.6); }
  input:focus, textarea:focus { background: #111815; }
  .connection, .icon-button { background: rgba(25,34,30,.76); }
  .step { color: rgba(238,245,241,.13); }
  .progress-track { background: #2a3530; }
  .task-button { color: #c4cec9; background: #28332f; }
  .empty-state { background: rgba(25,34,30,.42); }
}

/* Cloudreve visual alignment */
:root {
  --bg: #ffffff;
  --panel: #f5f5f5;
  --panel-strong: #f5f5f5;
  --ink: rgba(0, 0, 0, .87);
  --muted: rgba(0, 0, 0, .60);
  --line: rgba(0, 0, 0, .12);
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-soft: #e3f2fd;
  --accent: #1976d2;
  --danger: #d32f2f;
  --danger-soft: #ffebee;
  --shadow: none;
  --radius: 12px;
  color-scheme: light;
  font-family: Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

body {
  color: var(--ink);
  background: var(--bg);
  font-family: inherit;
}

button,
input,
textarea {
  font-family: inherit;
}

.ambient {
  display: none;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  padding: 0 0 32px;
}

.topbar {
  min-height: 64px;
  margin-bottom: 24px;
  padding: 11px 16px;
  background: var(--panel);
  border-radius: 0 0 12px 12px;
}

.brand {
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: #fff;
  background: var(--primary);
  border-radius: 50%;
  box-shadow: none;
  font-size: 19px;
  font-weight: 500;
}

.brand h1 {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 0;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
}

.connection {
  min-height: 42px;
  padding: 6px 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}

.connection-dot,
.connection.ready .connection-dot {
  background: var(--primary);
  box-shadow: none;
}

.hero-grid {
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 0;
  border-radius: 12px;
  box-shadow: none;
  backdrop-filter: none;
}

.create-panel,
.config-panel {
  padding: 24px;
}

.section-heading {
  margin-bottom: 20px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.section-heading h2,
.tasks-heading h2 {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0;
}

.step {
  color: var(--line);
  font-size: 26px;
  font-weight: 500;
}

.field > span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}

input,
textarea {
  padding: 11px 14px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, .23);
  border-radius: 12px;
  font-size: 14px;
}

input {
  min-height: 42px;
}

textarea {
  min-height: 84px;
}

input:focus,
textarea:focus {
  background: var(--bg);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.advanced {
  border-color: var(--line);
}

.advanced summary {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.primary-button {
  min-width: 156px;
  min-height: 42px;
  padding: 6px 16px;
  color: #fff;
  background: var(--primary);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}

.primary-button:hover {
  background: var(--primary-dark);
  transform: none;
}

.secondary-button {
  min-height: 42px;
  padding: 6px 16px;
  color: var(--primary);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
}

.secondary-button:hover {
  background: var(--primary-soft);
}

.config-list > div {
  border-color: var(--line);
}

.config-list dt,
.config-list dd,
.form-footer p,
.privacy-note,
.test-result {
  font-size: 12px;
}

.config-list dd {
  font-weight: 500;
}

.tasks-section {
  margin-top: 32px;
}

.icon-button {
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--panel);
  border: 0;
  border-radius: 12px;
}

.icon-button:hover {
  color: var(--primary);
  transform: none;
}

.empty-state,
.task-card {
  background: var(--panel);
  border: 0;
  border-radius: 12px;
  box-shadow: none;
}

.task-card {
  padding: 18px 20px;
}

.task-title h3 {
  font-size: 15px;
  font-weight: 500;
}

.status-badge {
  padding: 6px 10px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 500;
}

.status-badge.completed {
  color: #fff;
  background: var(--primary);
}

.progress-track {
  background: rgba(0, 0, 0, .10);
}

.progress-bar {
  background: var(--primary);
}

.task-button {
  padding: 7px 12px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
}

.task-button:hover {
  color: var(--primary);
  background: var(--primary-soft);
}

.toast {
  background: #323232;
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .24);
  font-size: 14px;
}

.sso-gate {
  background: rgba(0, 0, 0, .32);
  backdrop-filter: none;
}

.sso-card {
  padding: 32px;
  background: var(--bg);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .20);
}

.sso-card h1 {
  font-weight: 500;
}

.sso-card a {
  background: var(--primary);
  border-radius: 12px;
  font-weight: 500;
}

html[data-cloudreve-theme="dark"] {
  --bg: #121212;
  --panel: #1e1e1e;
  --panel-strong: #1e1e1e;
  --ink: rgba(255, 255, 255, .87);
  --muted: rgba(255, 255, 255, .60);
  --line: rgba(255, 255, 255, .12);
  --primary: #90caf9;
  --primary-dark: #64b5f6;
  --primary-soft: rgba(144, 202, 249, .14);
  --danger: #f44336;
  --danger-soft: rgba(244, 67, 54, .14);
  color-scheme: dark;
}

html[data-cloudreve-theme="dark"] input,
html[data-cloudreve-theme="dark"] textarea {
  border-color: rgba(255, 255, 255, .23);
}

html[data-cloudreve-theme="dark"] .progress-track {
  background: rgba(255, 255, 255, .10);
}

@media (max-width: 580px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding-top: 0;
  }

  .topbar {
    margin-bottom: 16px;
    border-radius: 0 0 12px 12px;
  }

  .create-panel,
  .config-panel {
    padding: 20px;
    border-radius: 12px;
  }
}
