:root {
  color-scheme: light;
  --canvas: #f7f3ec;
  --surface: #fffdf9;
  --surface-muted: #f0ebe3;
  --ink: #2d2925;
  --muted: #6c655e;
  --quiet: #6f665e;
  --line: #ded4c8;
  --line-strong: #c8b8a8;
  --copper: #9c5727;
  --copper-deep: #713a18;
  --copper-soft: #f1e2d5;
  --success: #327342;
  --success-soft: #e7f0e7;
  --danger: #a33b31;
  --danger-soft: #f7e8e5;
  --focus: #295ea8;
  --shadow: 0 10px 28px rgba(77, 49, 29, .09);
  --radius: 14px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, label[for]:focus-within {
  outline: 3px solid rgba(41, 94, 168, .32);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.login-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 50% 0, rgba(156, 87, 39, .09), transparent 42%),
    var(--canvas);
}
.login-surface {
  width: min(100%, 440px);
  padding: clamp(24px, 7vw, 38px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(77, 49, 29, .12);
  animation: reveal .42s var(--ease) both;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-mark { width: 42px; height: 42px; flex: 0 0 auto; }
.login-brand p, .login-brand h1 { margin: 0; }
.login-brand p { color: var(--muted); font-size: 12px; font-weight: 700; }
.login-brand h1 { margin-top: 2px; color: var(--copper-deep); font-size: clamp(26px, 7vw, 34px); line-height: 1.12; letter-spacing: -.03em; }
.login-intro { margin: 22px 0 20px; color: var(--muted); }
.login-service { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -5px 0 17px; padding: 9px 11px; color: var(--muted); background: var(--surface-muted); border-radius: 10px; font-size: 12px; }
.login-service > span { display: flex; align-items: center; gap: 8px; }
.login-service i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--quiet); }
.login-service.ready i { background: var(--success); }
.login-service.error { color: var(--danger); background: var(--danger-soft); }
.login-service.error i { background: var(--danger); }
.login-service b { font-weight: 700; }
.login-service button { min-height: 44px; flex: 0 0 auto; padding: 7px 10px; border: 1px solid #c9847d; border-radius: 8px; color: var(--danger); background: var(--surface); font-size: 12px; font-weight: 800; cursor: pointer; }
.login-service button:hover { color: #fff; background: var(--danger); }
.login-form { display: grid; gap: 15px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 62px; }
.password-field button {
  position: absolute; top: 0; right: 0; min-width: 56px; min-height: 44px;
  border: 0; border-radius: 8px; color: var(--copper-deep); background: transparent;
  font-size: 13px; font-weight: 800; cursor: pointer;
}
.password-field button:hover { background: var(--copper-soft); }
.remember-row { grid-template-columns: 22px 1fr; align-items: start; gap: 9px; cursor: pointer; }
.remember-row input { width: 20px; min-height: 20px; margin: 1px 0 0; accent-color: var(--copper); }
.remember-row span { display: grid; gap: 2px; color: var(--ink); }
.remember-row small { color: var(--muted); font-weight: 400; line-height: 1.45; }
.login-error { margin: -2px 0 0; padding: 10px 12px; color: var(--danger); background: var(--danger-soft); border-radius: 10px; font-size: 13px; }
.login-submit { width: 100%; min-height: 50px; margin-top: 2px; }
.login-proof { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.login-proof span { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.login-proof svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: var(--copper); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  min-height: 100vh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  gap: 16px;
}

.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark { width: 32px; height: 32px; stroke: var(--copper-deep); stroke-width: 2; fill: none; }
.brand-lockup h1 { margin: 0; font-family: "STSong", "Songti SC", serif; font-size: clamp(24px, 6vw, 32px); line-height: 1.05; letter-spacing: -.02em; color: var(--copper-deep); }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.account-summary { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--line); }
.account-summary > span { display: grid; line-height: 1.25; text-align: right; }
.account-summary strong { font-size: 13px; }
.account-summary small { color: var(--muted); font-size: 11px; }
.account-summary button { min-height: 38px; padding: 7px 9px; color: var(--copper-deep); background: transparent; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 700; cursor: pointer; }
.account-summary button:hover { background: var(--copper-soft); }
.install-app {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--copper-deep);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}
.install-app svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.connection {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 8px 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
}
.connection-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--quiet); box-shadow: 0 0 0 3px rgba(139,130,120,.13); }
.connection.online .connection-dot { background: var(--success); box-shadow: 0 0 0 3px rgba(50,115,66,.14); }
.connection.blocked .connection-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(163,59,49,.13); }

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  margin: 10px 0 26px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}
.view-tab {
  min-height: 46px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}
.view-tab.active { color: #fff; background: var(--copper); box-shadow: 0 5px 14px rgba(113,58,24,.18); }

.view.active { animation: reveal .42s var(--ease) both; }
@keyframes reveal { from { opacity: .35; transform: translateY(8px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

.workspace { display: grid; gap: 22px; }
.task-heading-row, .materials-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.task-heading-row h2, .materials-heading h2 { margin: 3px 0 0; font-size: clamp(21px, 5.6vw, 28px); line-height: 1.2; letter-spacing: -.02em; }
.task-state, .materials-heading p { margin: 0; color: var(--copper-deep); font-weight: 700; font-size: 13px; }
.task-switcher { margin: -4px 0 14px; max-width: 430px; }
.task-switcher select { background: var(--surface); }

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button.primary { color: #fff; background: var(--copper); box-shadow: 0 7px 18px rgba(113,58,24,.16); }
.button.primary:hover:not(:disabled) { background: var(--copper-deep); }
.button.secondary { color: var(--copper-deep); background: var(--surface); border-color: var(--copper); }
.button.secondary:hover:not(:disabled), .button.quiet:hover:not(:disabled) { background: var(--copper-soft); }
.button.quiet { color: var(--copper-deep); background: transparent; border-color: var(--line); }
.button.danger { color: var(--danger); background: var(--surface); border-color: #c9847d; box-shadow: none; }
.button.danger:hover:not(:disabled) { color: #fff; background: var(--danger); }
.button.text { min-height: 44px; padding-inline: 9px; color: var(--copper-deep); background: transparent; }
.button.full { width: 100%; }

.task-form-panel {
  margin: 0 0 18px;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: reveal .3s var(--ease) both;
}
.task-form-panel form { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
input, select {
  width: 100%; min-height: 44px; padding: 9px 11px;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 9px;
}
input::placeholder { color: #6f665e; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 3px; }

.capture-strip {
  padding: 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 7px 22px rgba(77,49,29,.07);
}
.capture-copy h3 { margin: 0; font-size: 17px; }
.capture-copy p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.capture-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.capture-button {
  min-height: 54px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--copper-deep); background: var(--copper-soft); border: 1px solid transparent; border-radius: 11px;
  cursor: pointer;
}
.capture-button:hover { border-color: var(--copper); }
.capture-button svg, .offline-cue svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.offline-cue { display: flex; align-items: center; gap: 7px; margin: 12px 0 0; color: var(--muted); font-size: 12px; }
.offline-cue svg { width: 17px; height: 17px; }

.nine-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.image-slot {
  position: relative;
  aspect-ratio: 1 / 1.18;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.slot-index {
  position: absolute; z-index: 2; top: 0; left: 0;
  min-width: 29px; min-height: 29px; padding: 2px 7px;
  display: grid; place-items: center;
  color: #fff; background: var(--quiet); border-radius: 0 0 9px 0;
  font-weight: 800;
}
.slot-visual { height: calc(100% - 35px); display: grid; place-items: center; overflow: hidden; background: #fbf8f3; }
.slot-visual img { width: 100%; height: 100%; object-fit: cover; }
.slot-icon { width: 32px; height: 32px; fill: none; stroke: #8b8278; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.slot-state { height: 35px; display: flex; align-items: center; justify-content: center; gap: 5px; padding: 4px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.slot-state svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.image-slot.ready .slot-index { background: var(--copper); }
.image-slot.ready .slot-state { color: var(--success); background: var(--success-soft); }
.image-slot.generating .slot-state { color: var(--copper-deep); background: var(--copper-soft); }
.image-slot.generating .slot-icon { animation: pulse 1.7s ease-in-out infinite; }
.image-slot.failed { border-color: var(--danger); }
.image-slot.failed .slot-index { background: var(--danger); }
.image-slot.failed .slot-state { color: var(--danger); background: var(--danger-soft); }
@keyframes pulse { 50% { opacity: .45; transform: scale(.92); } }

.status-strip {
  display: grid; grid-template-columns: 28px minmax(0,1fr) auto; align-items: center; gap: 11px;
  margin-top: 15px; padding: 13px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.status-strip > svg { width: 25px; height: 25px; fill: none; stroke: var(--copper); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.status-strip strong, .status-strip p { margin: 0; }
.status-strip p { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.action-panel {
  align-self: start;
  padding: 17px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}
.action-summary { margin-bottom: 4px; }
.action-summary p, .action-summary strong { margin: 0; }
.action-summary p { color: var(--muted); font-size: 13px; }
.action-summary strong { display: block; margin-top: 1px; font-size: 24px; color: var(--copper-deep); }
.linear-progress { height: 6px; margin-top: 10px; overflow: hidden; background: var(--surface-muted); border-radius: 6px; }
.linear-progress span { display: block; width: 100%; height: 100%; background: var(--copper); border-radius: inherit; transform: scaleX(0); transform-origin: left center; transition: transform .45s var(--ease); }
.cancel-note { margin: 1px 2px 0; color: var(--danger); font-size: 12px; overflow-wrap: anywhere; }
.boundary-note { margin: 5px 0 0; padding-top: 12px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }

.materials-heading { margin-top: 4px; }
.material-date-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 12px 0 16px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
}
.material-day {
  min-height: 52px;
  padding: 7px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: color .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.material-day strong, .material-day span { display: block; }
.material-day strong { color: var(--ink); font-size: 14px; }
.material-day span { margin-top: 1px; font-size: 12px; }
.material-day:hover { background: var(--copper-soft); }
.material-day.active { color: #fff; background: var(--copper); box-shadow: 0 5px 14px rgba(113,58,24,.15); }
.material-day.active strong { color: #fff; }
.materials-list { display: grid; gap: 12px; }
.material-item { display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 11px; padding: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.material-thumb {
  width: 78px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 5px;
  border-radius: 10px;
  background: var(--surface-muted);
}
.material-thumb span { min-width: 0; min-height: 0; border-radius: 2px; background: var(--copper-soft); }
.material-thumb span:nth-child(2n) { background: #e4d4c4; }
.material-thumb img { display: block; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; background: var(--surface-muted); }
.material-copy { min-width: 0; }
.material-item h3, .material-item p { margin: 0; }
.material-item h3 { overflow-wrap: anywhere; font-size: 15px; }
.material-item p { color: var(--muted); font-size: 12px; }
.empty-state { padding: 46px 22px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state svg { width: 43px; height: 43px; fill: none; stroke: var(--copper); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.empty-state h3 { margin: 14px 0 4px; }
.empty-state p { margin: 0 auto; max-width: 54ch; color: var(--muted); }

.toast {
  position: fixed; z-index: 20; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  width: min(calc(100% - 32px), 480px); transform: translateX(-50%);
  padding: 12px 15px; color: #fff; background: #3b332d; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(45,41,37,.25); text-align: center;
  animation: toast-in .3s var(--ease) both;
}
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (min-width: 720px) {
  .app-shell { padding-inline: 28px; }
  .view-tabs { width: 390px; margin-inline: auto; }
  .capture-strip { display: grid; grid-template-columns: 1fr minmax(340px, .8fr); align-items: center; gap: 18px; }
  .capture-actions { margin-top: 0; }
  .offline-cue { grid-column: 1 / -1; }
  .nine-grid { gap: 12px; }
  .image-slot { aspect-ratio: 1 / 1.1; }
}

@media (min-width: 940px) {
  .app-header { min-height: 74px; }
  .workspace { grid-template-columns: minmax(0, 1fr) 286px; align-items: start; }
  .action-panel { position: sticky; top: 18px; }
  .nine-grid { max-width: 700px; }
}

@media (max-width: 420px) {
  .app-shell { padding-inline: 12px; }
  .app-header { flex-wrap: wrap; }
  .brand-lockup p { display: none; }
  .header-actions { width: 100%; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .install-app { padding-inline: 9px; }
  .install-label { font-size: 0; }
  .install-label::after { content: "安装"; font-size: 12px; }
  .connection { font-size: 13px; }
  .account-summary { margin-left: auto; padding-left: 8px; }
  .account-summary > span { display: grid; text-align: left; }
  .account-summary small { display: none; }
  .task-form-panel form { grid-template-columns: 1fr; }
  .task-form-panel .field-wide { grid-column: 1; }
  .capture-strip { padding: 14px; }
  .capture-button { font-size: 13px; }
  .nine-grid { gap: 6px; }
  .slot-state { font-size: 11px; }
  .status-strip { grid-template-columns: 25px minmax(0,1fr); }
  .status-strip .button { grid-column: 1 / -1; justify-self: stretch; }
}
