:root {
  --bg: #faf7f2;
  --card: #ffffff;
  --line: #ece7df;
  --text: #23201c;
  --muted: #8b8378;
  --brand: #ff6b35;
  --brand-soft: #fff1ea;
  --ok: #2f9e5f;
  --ok-soft: #eaf7ef;
  --warn: #b8791f;
  --warn-soft: #fdf3e2;
  --err: #d64545;
  --err-soft: #fdecec;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }

/* header */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: var(--brand);
  color: #fff;
  border-radius: 13px;
  font-size: 24px;
  font-weight: 700;
  font-style: italic;
  box-shadow: 0 6px 16px rgba(255, 107, 53, .28);
}

.top h1 { font-size: 19px; margin: 0; letter-spacing: .5px; }
.top p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.chip {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12.5px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(30, 25, 20, .03);
}

.field { display: block; margin-bottom: 14px; }

.label {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: .3px;
}

textarea, input[type="text"], input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  background: #fcfbf9;
  border-radius: 12px;
  padding: 12px 13px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color .15s, background .15s;
  resize: vertical;
}

textarea:focus, input:focus {
  border-color: var(--brand);
  background: #fff;
}

textarea::placeholder, input::placeholder { color: #b3aca2; }

.row { display: flex; gap: 12px; }
.row .field { flex: 1; margin-bottom: 4px; }
.field.small input { text-align: left; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: transform .08s, opacity .15s, background .15s;
}

button:active { transform: scale(.985); }

.primary {
  background: var(--brand);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
}

.primary:disabled { opacity: .55; }

.primary.big { width: 100%; margin-top: 14px; padding: 15px; font-size: 16px; }

.ghost {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 9px;
}

.ghost:hover { background: #f2eee8; }

/* login */
.login h2 { margin: 0 0 4px; font-size: 17px; }
.login .hint { margin: 0 0 14px; }
.login form { display: flex; gap: 10px; }
.login input { flex: 1; }

/* banner */
.banner {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #f2e2c6;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}

/* list */
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 4px 12px;
}

.list-head h2 { font-size: 14px; margin: 0; color: var(--muted); font-weight: 600; letter-spacing: .4px; }
.head-actions { display: flex; align-items: center; gap: 8px; }

.jobs { display: flex; flex-direction: column; gap: 10px; }

.job {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
}

.job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.job-name {
  font-size: 15px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  font-weight: 500;
  flex-shrink: 0;
}

.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.queued, .badge.running { background: var(--brand-soft); color: var(--brand); }
.badge.pending { background: var(--warn-soft); color: var(--warn); }
.badge.failed { background: var(--err-soft); color: var(--err); }

.job-meta {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.job-msg { margin-top: 8px; font-size: 13px; }
.job-msg.err { color: var(--err); }

.job-files {
  margin-top: 10px;
  border-top: 1px dashed var(--line);
  padding-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 180px;
  overflow: auto;
}

.job-file {
  font-size: 13px;
  color: #4a453f;
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.job-file .dot { color: var(--brand); font-size: 10px; }

.job-actions { margin-top: 10px; display: flex; gap: 8px; justify-content: flex-end; }

.mini {
  font-size: 12.5px;
  color: var(--muted);
  background: #f6f2ec;
  border-radius: 8px;
  padding: 5px 10px;
}

.mini.danger { color: var(--err); background: var(--err-soft); }

.empty {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 28px 0;
}

.hint { font-size: 12.5px; color: var(--muted); }
.err { color: var(--err); font-size: 13px; margin: 10px 0 0; }

/* tabs */
.tabs {
  display: flex;
  gap: 6px;
  background: #f2eee8;
  padding: 4px;
  border-radius: 12px;
  margin: 4px 0 14px;
}

.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  padding: 9px 0;
  border-radius: 9px;
  font-weight: 500;
}

.tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(30, 25, 20, .08);
}

/* 文件浏览 */
.crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 2px 10px;
}

.crumbs button {
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  padding: 2px 4px;
  border-radius: 6px;
}

.crumbs button:hover { color: var(--brand); }
.crumbs .sep { color: #cfc7bb; }

.fs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fs-item {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 13px;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.fs-item:hover { border-color: #ddd5c9; }

.fs-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
  background: #f4f0ea;
}

.fs-icon.dir { background: var(--brand-soft); }

.fs-main { min-width: 0; flex: 1; }

.fs-name {
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fs-meta {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.fs-arrow { color: #c8c0b4; font-size: 15px; flex-shrink: 0; }

/* 阅读器 */
.viewer {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 20, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

.viewer-box {
  background: var(--bg);
  width: 100%;
  max-width: 680px;
  height: 88vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.viewer-head strong {
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.viewer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.viewer-actions a.mini { text-decoration: none; }

.viewer-body {
  flex: 1;
  overflow: auto;
  padding: 16px;
  font-size: 14.5px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  color: #33302b;
  -webkit-overflow-scrolling: touch;
}

.viewer-body.loading { color: var(--muted); }

.foot {
  margin-top: 26px;
  text-align: center;
  font-size: 12px;
  color: #b0a89d;
}

.foot b { color: var(--muted); font-weight: 600; }

.spin {
  display: inline-block;
  width: 11px; height: 11px;
  border: 2px solid rgba(255, 107, 53, .3);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -1px;
  margin-right: 5px;
}

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

@media (max-width: 420px) {
  .wrap { padding: 14px 13px calc(22px + env(safe-area-inset-bottom)); }
  .top h1 { font-size: 17px; }
  .card { padding: 15px; }
}
