:root {
  --bg: #f5f6f8;
  --fg: #1f2328;
  --muted: #6a737d;
  --primary: #2a64f5;
  --primary-hover: #1f4fdb;
  --border: #d0d7de;
  --card: #ffffff;
  --error: #c92a2a;
  --ok: #1f883d;
}

* {
  box-sizing: border-box;
}

/* 让 HTML 原生 hidden 属性在所有 display 下都生效，
   否则 .view { display: flex } 会把 hidden 的 display:none 覆盖掉 */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", Helvetica, Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 18px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

main {
  max-width: 760px;
  width: 100%;
  margin: 24px auto;
  padding: 0 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 26px;
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 14px;
}

.error {
  color: var(--error);
  margin: 10px 0 0;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

input[type="file"] {
  display: block;
  width: 100%;
  margin-bottom: 12px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-primary[disabled] {
  background: #adb5bd;
  cursor: not-allowed;
}

.btn-link {
  background: transparent;
  color: var(--primary);
  border: 0;
  cursor: pointer;
  padding: 4px 8px;
  font-size: 14px;
}
.btn-link:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 8px 0 14px;
}

.save-dir-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  flex-wrap: wrap;
}
.save-dir-info {
  font-size: 13px;
  color: var(--muted);
}

.meta {
  background: #f0f3f7;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--muted);
}

.stage-list {
  margin-top: 14px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
}
.stage-list .stage {
  padding: 6px 10px;
  border-radius: 6px;
  background: #f0f3f7;
}
.stage-list .stage.active {
  background: #fff7e0;
  color: #6d4c00;
}
.stage-list .stage.done {
  background: #ddf4e3;
  color: var(--ok);
}
.stage-list .stage.failed {
  background: #fbe5e5;
  color: var(--error);
}

.topic-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.topic-list li {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.topic-list .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.topic-list .title {
  font-weight: 600;
}
.topic-list .meta-line {
  font-size: 12px;
  color: var(--muted);
}
.topic-list .topic-status {
  font-size: 12px;
  color: var(--muted);
}
.topic-list .topic-status.ok {
  color: var(--ok);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}
.history-list .h-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.history-list .h-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  font-size: 12px;
}
.history-list .h-status {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #f0f3f7;
  color: var(--muted);
  align-self: flex-start;
}
.history-list .h-status.done { background: #ddf4e3; color: var(--ok); }
.history-list .h-status.failed { background: #fbe5e5; color: var(--error); }
.history-list .h-status.submitted,
.history-list .h-status.running,
.history-list .h-status.asr_done { background: #fff7e0; color: #6d4c00; }
.history-list .h-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 16px;
}
