:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #6b7280;
  --soft: #f5f5f7;
  --line: rgba(60, 60, 67, 0.16);
  --panel: rgba(255, 255, 255, 0.76);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --accent: #007aff;
  --accent-strong: #0057d9;
  --success: #34c759;
  --warning: #ffcc00;
  --danger: #ff3b30;
  --shadow: 0 24px 70px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, rgba(0, 122, 255, 0.18), transparent 32%),
    radial-gradient(circle at 86% 12%, rgba(52, 199, 89, 0.14), transparent 28%),
    linear-gradient(180deg, #f7f8fb 0%, #edf1f7 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.18));
}

button,
textarea,
select,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
  display: flex;
  align-items: stretch;
  position: relative;
}

.workspace {
  width: min(1180px, 100%);
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 0 6px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 820px;
  font-size: clamp(32px, 4.4vw, 58px);
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 800;
}

.status-pill {
  min-width: 132px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.64);
  color: var(--accent-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  font-size: 14px;
  font-weight: 700;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--success);
  box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.14);
}

.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
}

.panel-head {
  min-height: 92px;
  padding: 22px 22px 16px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  font-size: 21px;
  line-height: 1.2;
  font-weight: 750;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.icon-btn,
.copy-btn,
.ai-btn {
  height: 42px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.icon-btn {
  width: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(118, 118, 128, 0.12);
  color: #374151;
}

.copy-btn {
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 122, 255, 0.24);
}

.action-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-btn {
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(118, 118, 128, 0.12);
  color: #111827;
  font-weight: 700;
}

.ai-btn:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

textarea {
  width: calc(100% - 44px);
  height: 250px;
  margin: 22px;
  padding: 18px;
  border: 1px solid transparent;
  border-radius: 20px;
  resize: vertical;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  box-shadow:
    inset 0 0 0 1px rgba(60, 60, 67, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.9);
  line-height: 1.65;
  outline: none;
}

textarea::placeholder {
  color: rgba(60, 60, 67, 0.42);
}

textarea:focus,
select:focus,
input:focus-visible,
button:focus-visible {
  outline: 4px solid rgba(0, 122, 255, 0.16);
  outline-offset: 2px;
}

.controls {
  padding: 0 22px 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

label strong {
  color: var(--accent);
  font-weight: 750;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: rgba(118, 118, 128, 0.12);
  color: var(--ink);
  padding: 0 13px;
}

input[type="range"] {
  accent-color: var(--accent);
}

.switch-row {
  padding: 0 22px 22px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.switch-row label {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.68);
  color: #1f2937;
  font-size: 14px;
  font-weight: 650;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

pre {
  min-height: 394px;
  margin: 22px;
  padding: 20px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-radius: 22px;
  border: 1px solid rgba(60, 60, 67, 0.1);
  background: rgba(255, 255, 255, 0.9);
  color: #111827;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88);
  line-height: 1.68;
}

.score-row {
  padding: 0 22px 22px;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.score-value {
  font-size: 34px;
  line-height: 1;
  font-weight: 800;
  color: var(--accent);
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.meter {
  height: 12px;
  border-radius: 999px;
  background: rgba(118, 118, 128, 0.16);
  overflow: hidden;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--danger), var(--warning), var(--success));
  transition: width 180ms ease;
}

.template-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.template-strip button {
  min-height: 58px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
  color: #111827;
  box-shadow: 0 12px 32px rgba(31, 41, 55, 0.08);
  cursor: pointer;
  font-weight: 700;
  text-align: left;
  backdrop-filter: blur(18px) saturate(170%);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
}

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

button:active {
  transform: scale(0.98);
}

@media (max-width: 900px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .editor-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar {
    align-items: start;
  }

  .controls,
  .switch-row,
  .template-strip {
    grid-template-columns: 1fr 1fr;
  }

  pre {
    min-height: 320px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  h1 {
    font-size: 32px;
  }

  .panel {
    border-radius: 24px;
  }

  .panel-head {
    padding: 18px;
    flex-direction: column;
  }

  .action-group,
  .copy-btn,
  .ai-btn {
    width: 100%;
    justify-content: center;
  }

  textarea,
  pre {
    width: calc(100% - 36px);
    margin: 18px;
  }

  .controls,
  .switch-row,
  .template-strip,
  .score-row {
    grid-template-columns: 1fr;
  }
}
