@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg0: #0f1419;
  --bg1: #1a222c;
  --bg2: #243040;
  --bg3: #2e3d4f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #2dd4a8;
  --accent-dim: rgba(45, 212, 168, 0.15);
  --accent2: #5b9fd4;
  --warn: #e8a838;
  --danger: #e85d5d;
  --radius: 12px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg0);
}

body {
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(45, 212, 168, 0.12), transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(91, 159, 212, 0.1), transparent 45%),
    linear-gradient(180deg, #121820 0%, var(--bg0) 40%, #0c1015 100%);
  background-attachment: fixed;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.72);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-brand:hover {
  text-decoration: none;
  color: var(--accent);
}

.site-brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  color: #0a1210;
}

.btn-home {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.btn-home:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  text-decoration: none;
  color: var(--accent);
  transform: translateY(-1px);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.hero {
  text-align: center;
  margin-bottom: 48px;
  animation: fadeUp 0.55s ease both;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero h1 span {
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.hero .cache-tip {
  margin-top: 10px;
  font-size: 0.88rem;
  color: var(--warn);
  opacity: 0.9;
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 0 0 16px;
  font-weight: 600;
}

.primary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 48px;
  animation: fadeUp 0.55s ease 0.08s both;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  animation: fadeUp 0.55s ease 0.16s both;
}

.card {
  display: block;
  padding: 28px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(36, 48, 64, 0.9), rgba(26, 34, 44, 0.95));
  box-shadow: var(--shadow);
  color: var(--text);
  text-decoration: none;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(45, 212, 168, 0.06));
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(45, 212, 168, 0.45);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  text-decoration: none;
  color: var(--text);
}

.card:hover::before {
  opacity: 1;
}

.card.primary {
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.card .icon {
  font-size: 1.75rem;
  margin-bottom: 12px;
  opacity: 0.9;
}

.card h2, .card h3 {
  margin: 0 0 6px;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  position: relative;
}

.card.tool h3 {
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
  position: relative;
}

.tool-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.tool-page h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}

.tool-page .desc {
  color: var(--muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(26, 34, 44, 0.85);
  padding: 20px;
  margin-bottom: 16px;
}

.panel label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.panel textarea,
.panel input[type="text"],
.panel input[type="number"],
.panel select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg0);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.88rem;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.panel textarea:focus,
.panel input:focus,
.panel select:focus {
  border-color: var(--accent);
}

.panel textarea {
  min-height: 140px;
  line-height: 1.5;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: #062018;
}

.btn-primary:hover {
  background: #3ee0b6;
}

.btn-secondary {
  background: var(--bg2);
  border-color: var(--line);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent2);
  background: rgba(91, 159, 212, 0.12);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 8px;
}

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg3);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin: 8px 0 4px;
}

.check-group label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.check-group input {
  accent-color: var(--accent);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .primary-grid,
  .row-2 {
    grid-template-columns: 1fr;
  }

  .site-header {
    padding: 12px 16px;
  }

  .page,
  .tool-page {
    padding: 24px 16px 48px;
  }
}

/* —— 大窗口双栏编辑器（HTML / XML） —— */
html.editor-full,
html.editor-full body {
  height: 100%;
  overflow: hidden;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-shell .site-header {
  flex-shrink: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(26, 34, 44, 0.9);
  flex-shrink: 0;
}

.editor-toolbar .title {
  font-weight: 650;
  margin-right: 8px;
  letter-spacing: -0.02em;
}

.editor-toolbar .spacer {
  flex: 1;
}

.editor-main {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
  width: 100%;
}

.editor-pane {
  height: 100%;
  min-width: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.editor-pane.left {
  width: 42%;
}

.editor-pane.right {
  width: 58%;
  flex: 1;
}

.editor-pane .pane-label {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  background: rgba(15, 20, 25, 0.5);
}

.editor-pane textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  resize: none;
  padding: 14px 16px;
  background: var(--bg0);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.55;
  outline: none;
}

.editor-pane textarea:focus {
  background: #0c1015;
}

.editor-drag {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 5;
}

.editor-drag::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: var(--line);
  transition: background 0.15s;
}

.editor-drag:hover::after,
.editor-drag.active::after {
  background: var(--accent);
}

.editor-actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(26, 34, 44, 0.95);
  flex-shrink: 0;
}

.win-btns {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.win-btns button {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
}

.win-btns button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* HTML / XML 白色背景主题 */
html.editor-light,
html.editor-light body {
  color: #222;
  background: #fff;
}

html.editor-light body {
  background: #fff;
}

html.editor-light .editor-shell {
  background: #fff;
}

html.editor-light .site-header {
  background: #fff;
  border-bottom: 1px solid #e5e8ec;
}

html.editor-light .site-brand {
  color: #1a222c;
}

html.editor-light .site-brand:hover {
  color: #0d9488;
}

html.editor-light .btn-home {
  background: #fff;
  color: #333;
  border-color: #d0d5dd;
}

html.editor-light .btn-home:hover {
  color: #0d9488;
  border-color: #0d9488;
  background: #f0fdfa;
}

html.editor-light .win-btns button {
  background: #f5f7fa;
  color: #556;
  border-color: #d0d5dd;
}

html.editor-light .win-btns button:hover {
  border-color: #0d9488;
  color: #0d9488;
  background: #f0fdfa;
}

html.editor-light .editor-toolbar {
  background: #f7f9fb;
  border-bottom: 1px solid #e5e8ec;
  color: #222;
}

html.editor-light .editor-toolbar .hint {
  color: #8899aa;
}

html.editor-light .editor-main {
  background: #fff;
}

html.editor-light .editor-pane .pane-label {
  color: #667788;
  background: #fafbfc;
  border-bottom: 1px solid #eef1f4;
}

html.editor-light .editor-pane textarea {
  background: #fff;
  color: #222;
}

html.editor-light .editor-pane textarea:focus {
  background: #fff;
}

html.editor-light .editor-pane textarea::placeholder {
  color: #aabbcc;
}

html.editor-light .editor-drag::after {
  background: #e5e8ec;
}

html.editor-light .editor-drag:hover::after,
html.editor-light .editor-drag.active::after {
  background: #0d9488;
}

html.editor-light .btn-secondary {
  background: #f0f3f6;
  border-color: #d0d5dd;
  color: #333;
}

html.editor-light .btn-secondary:hover {
  border-color: #5b9fd4;
  background: #eef5fb;
}

html.editor-light .btn-ghost {
  border-color: #d0d5dd;
  color: #556;
}

html.editor-light .btn-ghost:hover {
  color: #222;
  border-color: #aabbcc;
  background: #f5f7fa;
}

/* —— 历史记录面板（约 10% 宽） —— */
.history-pane {
  display: none;
  flex-direction: column;
  width: 10%;
  min-width: 118px;
  max-width: 168px;
  flex: 0 0 10%;
  height: 100%;
  border-right: 1px solid var(--line, #e5e8ec);
  background: rgba(15, 20, 25, 0.55);
  overflow: hidden;
}

body.history-open .history-pane,
.editor-main.has-history .history-pane {
  display: flex;
}

body.history-open .editor-pane.left {
  width: 40%;
}

.history-head {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--line, #e5e8ec);
  font-size: 0.78rem;
  font-weight: 650;
}

.history-clear {
  border: 0;
  background: transparent;
  color: var(--muted, #889);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 4px;
}

.history-clear:hover {
  color: var(--danger, #e85d5d);
}

.history-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.history-empty {
  padding: 16px 8px;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted, #889);
  line-height: 1.5;
}

.history-item {
  padding: 8px 8px;
  margin-bottom: 6px;
  border-radius: 6px;
  border: 1px solid var(--line, #e5e8ec);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.history-item:hover {
  border-color: #5b9fd4;
  background: rgba(91, 159, 212, 0.12);
}

.history-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 4px;
}

.history-item-time {
  font-size: 0.68rem;
  color: var(--muted, #889);
}

.history-item-del {
  border: 0;
  background: transparent;
  color: #99a;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}

.history-item-del:hover {
  color: #e85d5d;
}

.history-item-preview {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text, #dde);
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-toggle.active {
  background: #145ccd !important;
  color: #fff !important;
  border-color: #145ccd !important;
}

html.editor-light .history-pane {
  background: #f4f7fa;
  border-right-color: #e5e8ec;
}

html.editor-light .history-item {
  background: #fff;
  border-color: #e5e8ec;
}

html.editor-light .history-item:hover {
  background: #eef6ff;
  border-color: #145ccd;
}

html.editor-light .history-item-preview {
  color: #334;
}

html.editor-light .history-empty,
html.editor-light .history-item-time,
html.editor-light .history-clear {
  color: #8899aa;
}
