:root {
  --text: #2b2f36;
  --muted: #7b8494;
  --accent: #1677ff;
  --accent-hover: #0958d9;
  --panel: #ffffff;
  --panel-muted: #f5f7fb;
  --line: #dce3ed;
  --line-strong: #c9d3e1;
  --success: #1f8f55;
  --warn: #d48806;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius-lg: 10px;
  --radius-md: 8px;
  --mono: "JetBrains Mono", "Cascadia Code", "SFMono-Regular", "Consolas", monospace;
  --sans: "Segoe UI", "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: #f3f5f8;
  color: var(--text);
  font-family: var(--sans);
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 14px;
}

.toolbar-card {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn {
  min-width: 92px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}

.action-btn:hover {
  color: var(--accent);
  border-color: #9dc2ff;
}

.action-btn:focus-visible,
textarea:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid #91caff;
  outline-offset: 2px;
}

.action-btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.action-btn-primary:hover {
  color: #fff;
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.status-text {
  margin: 8px 2px 0;
  min-height: 1.5em;
  color: var(--muted);
  font-size: 12px;
}

.status-text[data-tone="success"] {
  color: var(--success);
}

.status-text[data-tone="warn"] {
  color: var(--warn);
}

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

.panel {
  min-height: calc(100vh - 84px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.panel-output {
  background: var(--panel);
}

textarea {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 84px);
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  padding: 14px;
  resize: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
}

textarea::placeholder {
  color: #a0a9b8;
}

#rawInput {
  background: var(--panel);
}

#formattedOutput {
  background: var(--panel-muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
}

.modal-card {
  position: relative;
  width: min(640px, calc(100vw - 24px));
  margin: 8vh auto 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.modal-copy {
  margin: 10px 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-textarea {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-muted);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 42vh;
  }
}

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

  .toolbar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .action-btn {
    width: 100%;
    min-width: 0;
  }

  .modal-card {
    margin-top: 12px;
  }
}
