:root {
  --bg: #eef2f9;
  --bg2: #e3e9f5;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7688;
  --line: #e2e8f0;
  --primary: #4f6ef7;
  --primary-dark: #3b57d8;
  --ok: #12855a;
  --warn: #b45309;
  --err: #c02d2d;
  --shadow: 0 10px 40px -12px rgba(24, 39, 75, .18), 0 2px 8px rgba(24, 39, 75, .06);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 8% -10%, #dfe7ff 0%, transparent 60%),
    radial-gradient(900px 500px at 108% 8%, #e9e1ff 0%, transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}

.card {
  width: min(680px, 100%);
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------------------------------------------------------------- 头部 */

.head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: .2px;
}

.updated {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ------------------------------------------------------------ 状态条 */

.statusbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f1f5fb;
  color: var(--muted);
  font-size: 13.5px;
  transition: background .2s, color .2s, border-color .2s;
}

.statusbar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}

.statusbar.ok   { background: #e8f7ef; color: var(--ok);   border-color: #c6ecd9; }
.statusbar.warn { background: #fff5e6; color: var(--warn); border-color: #ffe0b3; }
.statusbar.err  { background: #fdecec; color: var(--err);  border-color: #f8cfcf; }

/* -------------------------------------------------------------- 内容 */

.display {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fafbfd;
  padding: 16px;
  min-height: 128px;
  max-height: 46vh;
  overflow: auto;
}

.content {
  margin: 0;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
}

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

/* -------------------------------------------------------------- 按钮 */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}

.btn:hover { border-color: #c9d4e6; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(79, 110, 247, .35); outline-offset: 2px; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 550;
}

.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.copybar { display: flex; justify-content: center; }
.copybar .btn { padding: 12px 28px; }

/* ------------------------------------------------------------ 上传区 */

.upload {
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.upload summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  list-style: none;
  user-select: none;
  width: fit-content;
}

.upload summary::-webkit-details-marker { display: none; }

.upload summary::before {
  content: "＋";
  display: inline-block;
  margin-right: 6px;
  transition: transform .2s;
}

.upload[open] summary::before { transform: rotate(45deg); }

.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

textarea,
input {
  width: 100%;
  font: inherit;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 11px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

textarea {
  resize: vertical;
  min-height: 110px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
}

textarea:focus,
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 110, 247, .14);
}

.row { display: flex; gap: 10px; }
.row input { flex: 1; min-width: 0; }

.msg {
  margin: 0;
  min-height: 1.2em;
  font-size: 13px;
  color: var(--muted);
}

.msg.ok  { color: var(--ok); }
.msg.err { color: var(--err); }

/* ------------------------------------------------------------ 响应式 */

@media (max-width: 520px) {
  .card { padding: 18px; border-radius: 16px; }
  .row { flex-direction: column; }
  .display { max-height: 40vh; }
  .copybar .btn { width: 100%; }
}

/* -------------------------------------------------------------- 暗色 */

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1320;
    --bg2: #131b2b;
    --card: #161d2b;
    --text: #e8edf7;
    --muted: #93a0b5;
    --line: #26314a;
    --primary: #6d84ff;
    --primary-dark: #8296ff;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --shadow: 0 10px 40px -12px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .35);
  }

  body {
    background:
      radial-gradient(1200px 600px at 8% -10%, rgba(79, 110, 247, .16) 0%, transparent 60%),
      radial-gradient(900px 500px at 108% 8%, rgba(140, 100, 255, .12) 0%, transparent 55%),
      linear-gradient(160deg, var(--bg), var(--bg2));
  }

  .card { border-color: rgba(255, 255, 255, .06); }
  .display { background: #121926; }
  .statusbar { background: #1b2334; }
  .statusbar.ok   { background: rgba(74, 222, 128, .10); border-color: rgba(74, 222, 128, .28); }
  .statusbar.warn { background: rgba(251, 191, 36, .10); border-color: rgba(251, 191, 36, .28); }
  .statusbar.err  { background: rgba(248, 113, 113, .10); border-color: rgba(248, 113, 113, .28); }
  .btn { background: #1b2334; }
  .btn:hover { border-color: #35425f; }
  .btn.primary { background: var(--primary); border-color: var(--primary); color: #0e1320; }
  .btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
  textarea, input { background: #121926; }
}
