:root {
  --ink: #152033;
  --muted: #5d6b80;
  --line: #d9e0ea;
  --paper: #f3f6fb;
  --card: #ffffff;
  --blue: #1877f2;
  --blue-dark: #0d5fce;
  --good: #0f8a4b;
  --bad: #c0392b;
  --shadow: 0 12px 40px rgba(21, 32, 51, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 8% -10%, #d7e6ff 0, transparent 32%),
    radial-gradient(circle at 100% 0, #ffe8d2 0, transparent 28%),
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.top { margin-bottom: 22px; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 30px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(24, 119, 242, 0.28);
}

h1, h2, p { margin: 0; }
h1 { font-size: 26px; letter-spacing: 0.02em; }
h2 { font-size: 18px; }
.brand p, .result-head p, .hint { color: var(--muted); font-size: 13px; }

.layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.tabs {
  display: flex;
  background: #eef3f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 9px 0;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(21, 32, 51, 0.08);
}

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 220px;
  border: 1.5px dashed #9db6d6;
  border-radius: 14px;
  background: #f7faff;
  cursor: pointer;
  text-align: center;
  padding: 20px;
}

.drop.is-over,
.drop.has-file {
  border-color: var(--blue);
  background: #eaf2ff;
}

.drop.has-file { border-style: solid; }
.drop.has-file strong { color: var(--blue); word-break: break-all; }

.drop strong { font-size: 16px; }
.drop span, .drop em { color: var(--muted); font-size: 13px; font-style: normal; }
.drop em { color: var(--blue); }

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: 13px/1.5 Consolas, "Courier New", monospace;
  color: var(--ink);
  background: #fbfcfe;
}

textarea:focus, button:focus { outline: 2px solid #9cc2f7; outline-offset: 2px; }

.actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

button {
  font: inherit;
  cursor: pointer;
}

.primary, .ghost, .mini {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 10px 16px;
  font-weight: 700;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.primary:hover { background: var(--blue-dark); }
.primary:disabled {
  background: #9bb8de;
  cursor: not-allowed;
}

.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.hint { margin-top: 12px; }

.result-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.empty, .error {
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: #f7f9fc;
}

.error {
  background: #fdeeee;
  color: var(--bad);
  padding: 10px 12px;
  margin-bottom: 12px;
  text-align: left;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th { background: #f6f8fc; color: var(--muted); font-weight: 600; }
tbody tr { cursor: pointer; }
tbody tr:hover, tbody tr.is-on { background: #eef5ff; }

.ok { color: var(--good); font-weight: 700; }
.fail { color: var(--bad); font-weight: 700; }

.detail {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card h3 { font-size: 13px; }
.mini {
  padding: 5px 10px;
  background: #eef3f9;
  color: var(--ink);
  font-size: 12px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font: 12px/1.45 Consolas, "Courier New", monospace;
  color: #243247;
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .result-head { flex-direction: column; }
}

.shell {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.workspace { flex: 1; min-width: 0; }

.sidebar {
  width: 232px;
  flex: none;
  position: sticky;
  top: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 12px 14px;
  max-height: calc(100vh - 32px);
  overflow: auto;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}

.side-brand .mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 24px;
}

.side-brand strong { display: block; font-size: 18px; }
.side-brand em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.side-nav { display: grid; gap: 4px; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: #3c4d66;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 650;
  text-align: left;
}

.nav-item svg { flex: none; }
.nav-item:hover { background: #f4f7fb; }
.nav-item.is-on {
  background: #e8f1ff;
  color: var(--blue);
}

.menu-btn, .backdrop { display: none; }

.view-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px 26px 30px;
}

.view-card h2 { font-size: 28px; }
.lead {
  color: #526278;
  font-size: 14px;
  line-height: 1.7;
  margin: 10px 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.template-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.template-row span, .hint { line-height: 1.5; }

a.ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.totp-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.totp-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfe;
}

.totp-secret {
  width: 100%;
  border: 1.5px solid #8fbf7a;
  border-radius: 12px;
  padding: 14px 12px;
  font: 16px/1.4 Consolas, "Courier New", monospace;
  text-align: center;
  color: var(--ink);
  background: #fff;
}

.totp-actions, .totp-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.totp-actions span, .totp-line { color: #526278; font-size: 14px; }
.totp-line { margin-top: 10px; }
.totp-code {
  font-size: 28px;
  letter-spacing: 0.12em;
  color: var(--ink);
}

.totp-left.fresh { color: var(--good); }
.totp-left.warn { color: #b26a00; }
.totp-left.urgent { color: var(--bad); }

.totp-get, .totp-qr {
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 700;
  border: 1px solid transparent;
}

.totp-get { background: #1f9d55; color: #fff; }
.totp-get:hover { background: #178746; }
.totp-qr {
  background: #fff;
  color: #178746;
  border-color: #1f9d55;
}

.totp-msg {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--bad);
  font-size: 13px;
}

.qr-slot {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  background: #fff;
  border-radius: 12px;
  padding: 8px;
}

.notes-label {
  display: block;
  margin: 18px 0 8px;
  font-weight: 700;
}

textarea.notes { min-height: 120px; }
textarea.query-text { min-height: 160px; }

.linkish {
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.group-title {
  margin: 22px 0 12px;
  font-size: 18px;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.link-card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  min-height: 78px;
}

.link-card:hover {
  border-color: #9cc2f7;
  background: #f5f9ff;
}

.link-card strong { display: block; margin-bottom: 4px; }
.link-card span { color: var(--muted); font-size: 12px; line-height: 1.45; }

.query-panel .tabs { margin-top: 4px; max-width: 460px; }
.friend-mode { margin: 0 0 12px; }
.tone-ok { color: var(--good); font-weight: 700; }
.tone-bad { color: var(--bad); font-weight: 700; }
.tone-warn { color: #b26a00; font-weight: 700; }

.query-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 0 10px;
}

.query-summary h3 { margin: 0; font-size: 18px; }

.split-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.split-result textarea { min-height: 160px; }

.danger {
  background: #e5534b;
  color: #fff;
  border-radius: 10px;
  border: 0;
  padding: 10px 16px;
  font-weight: 700;
}

.danger:hover { background: #c9433c; }

@media (max-width: 900px) {
  .menu-btn {
    display: grid;
    place-items: center;
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 30;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 8px 18px rgba(21, 32, 51, 0.16);
    font-size: 20px;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    left: 12px;
    top: 12px;
    bottom: 12px;
    max-height: none;
    transform: translateX(-120%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open { transform: none; }

  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(21, 32, 51, 0.28);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .backdrop.is-on {
    opacity: 1;
    pointer-events: auto;
    z-index: 35;
  }

  .totp-grid, .split-result { grid-template-columns: 1fr; }
  .workspace { padding-top: 8px; }
  .view-card { padding: 18px 14px 22px; }
  .view-card h2 { font-size: 24px; }
}
