:root {
  --bg-primary: #f6f1ea;
  --bg-surface: #ffffff;
  --bg-elevated: #fbfaf8;
  --border: #e8e0d6;
  --border-bright: #d8cdc0;
  --accent: #ff3f68;
  --accent-glow: rgba(255, 63, 104, 0.16);
  --accent-2: #b87618;
  --success: #12b8a6;
  --danger: #e95757;
  --text-primary: #232323;
  --text-secondary: #555555;
  --text-muted: #a8a8a8;
  --field-bg: #fffaf2;
  --field-border: #eadfce;
  --field-bg-focus: #fffdf8;
  --output-bg: #fbfefe;
  --output-border: #d7e8e5;
  --output-muted-bg: #f3f9f8;
  --shadow-soft: 0 16px 44px rgba(67, 50, 36, 0.08);
  --shadow-card: 0 8px 24px rgba(67, 50, 36, 0.055);
  --radius: 8px;
  --radius-inner: 6px;
  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Menlo", "Consolas", monospace;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-primary);
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 63, 104, 0.10), transparent 28%),
    linear-gradient(135deg, #fffaf6 0%, var(--bg-primary) 42%, #f1f6f4 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.52) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.52) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .7), rgba(0, 0, 0, .08));
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100vw - 32px));
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  animation: fadeInUp .45s ease both;
}

.global-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.app-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 12px 28px rgba(255, 63, 104, 0.22);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
}

.global-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(232, 224, 214, 0.72);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(67, 50, 36, 0.045);
  backdrop-filter: blur(14px);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .74);
  color: var(--text-secondary);
  font-size: 12px;
  white-space: nowrap;
  text-decoration: none;
}

.status-pill i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 9px rgba(18, 184, 166, .5);
}

.status-pill.muted { color: var(--text-muted); }

.contact-link:hover {
  border-color: rgba(255, 63, 104, .35);
  color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(232, 224, 214, .92);
  border-radius: 16px;
  background: rgba(255, 255, 255, .78);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}

.input-panel,
.result-panel {
  min-height: calc(100dvh - 126px);
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 12px;
}

.panel-header label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

textarea {
  flex: 0 0 auto;
  width: 100%;
  min-height: calc(10 * 1.8em + 32px);
  height: calc(10 * 1.8em + 32px);
  max-height: calc(10 * 1.8em + 32px);
  resize: none;
  overflow: auto;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  padding: 16px;
  background: var(--field-bg);
  color: var(--text-primary);
  font: 14px/1.8 var(--font-ui);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

textarea:focus {
  border-color: rgba(255, 63, 104, .55);
  background: var(--field-bg-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .8);
}

textarea::placeholder { color: #b7aa9c; }

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.hint {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 36px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, .88);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-bright);
  color: var(--text-primary);
}

.btn:active:not(:disabled) { transform: scale(.98); }

.btn:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.btn-small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-primary {
  min-width: 112px;
  border-color: transparent;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(255, 63, 104, .22);
}

.btn-primary:hover:not(:disabled) {
  color: #fff;
  box-shadow: 0 12px 30px rgba(255, 63, 104, .28);
}

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, .52);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.is-loading .btn-spinner { display: block; }

.result-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  border: 1px dashed var(--output-border);
  border-radius: 14px;
  background: var(--output-muted-bg);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.result-placeholder.has-result {
  display: block;
  align-items: initial;
  justify-content: initial;
  overflow: auto;
  padding: 20px 24px;
  border-style: solid;
  background: var(--output-bg);
  color: var(--text-primary);
  text-align: left;
  line-height: 1.82;
}

.result-box {
  flex: 1;
  min-height: 280px;
  overflow: auto;
  padding: 20px 24px;
  border: 1px solid var(--output-border);
  border-radius: 14px;
  background: var(--output-bg);
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.82;
}

.result-box h1,
.result-box h2,
.result-box h3 {
  margin: 20px 0 10px;
  line-height: 1.45;
}

.result-box h1:first-child,
.result-box h2:first-child,
.result-box h3:first-child { margin-top: 0; }

.result-box h1 { font-size: 17px; color: var(--accent); }
.result-box h2 {
  font-size: 15px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.result-box h3 { font-size: 14px; color: var(--success); }
.result-box p { margin: 8px 0 14px; }
.result-box strong { color: var(--accent); font-weight: 700; }
.result-box ul,
.result-box ol { margin: 8px 0 16px; padding-left: 24px; }
.result-box li { margin: 6px 0; }
.result-box li::marker { color: var(--accent); }
.result-box code {
  border: 1px solid var(--output-border);
  border-radius: 4px;
  background: #eef5f4;
  color: var(--accent-2);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.result-box table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
  background: var(--bg-surface);
  box-shadow: 0 0 0 1px var(--output-border);
}
.result-box th,
.result-box td {
  border: 1px solid var(--output-border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}
.result-box th {
  color: var(--accent);
  background: #fff5f7;
}
.result-box .error {
  color: var(--danger);
  font-weight: 700;
}

.result-placeholder.has-result h1,
.result-placeholder.has-result h2,
.result-placeholder.has-result h3 {
  margin: 20px 0 10px;
  line-height: 1.45;
}

.result-placeholder.has-result h1:first-child,
.result-placeholder.has-result h2:first-child,
.result-placeholder.has-result h3:first-child { margin-top: 0; }

.result-placeholder.has-result h1 { font-size: 17px; color: var(--accent); }
.result-placeholder.has-result h2 {
  font-size: 15px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.result-placeholder.has-result h3 { font-size: 14px; color: var(--success); }
.result-placeholder.has-result p { margin: 8px 0 14px; }
.result-placeholder.has-result strong { color: var(--accent); font-weight: 700; }
.result-placeholder.has-result ul,
.result-placeholder.has-result ol { margin: 8px 0 16px; padding-left: 24px; }
.result-placeholder.has-result li { margin: 6px 0; }
.result-placeholder.has-result li::marker { color: var(--accent); }
.result-placeholder.has-result code {
  border: 1px solid var(--output-border);
  border-radius: 4px;
  background: #eef5f4;
  color: var(--accent-2);
  padding: 1px 5px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.result-placeholder.has-result table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin: 14px 0 22px;
  background: var(--bg-surface);
  box-shadow: 0 0 0 1px var(--output-border);
}
.result-placeholder.has-result th,
.result-placeholder.has-result td {
  border: 1px solid var(--output-border);
  padding: 9px 11px;
  text-align: left;
  vertical-align: top;
}
.result-placeholder.has-result th {
  color: var(--accent);
  background: #fff5f7;
}
.result-placeholder.has-result .error {
  color: var(--danger);
  font-weight: 700;
}

@media (max-width: 860px) {
  .app-shell {
    width: auto;
    max-width: none;
    margin-right: 12px;
    margin-left: 12px;
    padding: 14px 0;
  }

  .global-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .global-controls {
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .workspace {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .panel {
    width: 100%;
    max-width: calc(100vw - 24px);
    overflow: hidden;
  }

  .input-panel,
  .result-panel {
    min-height: auto;
  }

  textarea {
    min-height: 240px;
  }

  .action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }
}
