:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --surface-muted: rgba(245, 247, 250, 0.86);
  --line: rgba(31, 41, 55, 0.11);
  --line-strong: rgba(31, 41, 55, 0.18);
  --text: #111827;
  --muted: #6b7280;
  --accent: #0a84ff;
  --accent-dark: #0066cc;
  --green: #2f7d63;
  --code: #eef2f7;
  --shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
  --soft-shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(10, 132, 255, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(47, 125, 99, 0.08), transparent 38%),
    var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.03);
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:hover {
  border-color: var(--line-strong);
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: rgba(10, 132, 255, 0.62);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(10, 132, 255, 0.26);
}

button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.app-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 38px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.02;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.status-pill {
  flex: 0 0 auto;
  border: 1px solid rgba(47, 125, 99, 0.2);
  border-radius: 999px;
  color: #1f6b52;
  background: rgba(236, 252, 243, 0.76);
  padding: 8px 13px;
  font-size: 13px;
  backdrop-filter: blur(18px);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(520px, 1.08fr);
  gap: 18px;
  align-items: stretch;
  min-height: calc(100vh - 158px);
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px);
}

.input-panel,
.result-shell {
  min-height: 680px;
}

.panel-header,
.panel-actions {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.52);
  padding: 14px 16px;
}

.panel-header h2,
.panel-actions h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 680;
  line-height: 1.2;
}

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

textarea {
  display: block;
  width: 100%;
  min-height: 614px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.46);
  line-height: 1.62;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
}

textarea::placeholder {
  color: #98a2b3;
}

.result-shell {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.66)),
    var(--surface);
}

.result-empty {
  min-height: 680px;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 34px;
  text-align: center;
}

.empty-mark {
  width: 66px;
  height: 66px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface-strong);
  color: var(--accent);
  box-shadow: var(--soft-shadow);
  font-size: 28px;
  font-weight: 650;
}

.result-empty h2 {
  margin: 18px 0 6px;
  font-size: 22px;
}

.result-empty p {
  margin: 0;
  color: var(--muted);
}

.result-content {
  min-height: 680px;
  display: grid;
  grid-template-rows: auto 1fr;
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 250, 0.7);
  padding: 10px;
}

.tab-button {
  min-width: 0;
  min-height: 40px;
  border-radius: 14px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  box-shadow: none;
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.68);
  box-shadow: none;
}

.tab-button.active {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.tab-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel textarea {
  min-height: 570px;
  background: rgba(255, 255, 255, 0.62);
}

#markdownOutput,
#plainOutput {
  overflow: hidden;
}

.preview {
  min-height: 570px;
  overflow: auto;
  padding: 26px;
  outline: 0;
  background: rgba(255, 255, 255, 0.62);
  line-height: 1.75;
}

.preview h1,
.preview h2,
.preview h3 {
  line-height: 1.25;
}

.preview h1 {
  font-size: 30px;
}

.preview h2 {
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  font-size: 24px;
}

.preview h3 {
  font-size: 19px;
}

.preview p,
.preview ul,
.preview ol,
.preview pre,
.preview blockquote {
  margin: 0 0 14px;
}

.preview code {
  border-radius: 6px;
  background: var(--code);
  padding: 2px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}

.preview pre {
  overflow: auto;
  border-radius: 14px;
  background: #111827;
  color: #f8fafc;
  padding: 14px;
}

.preview pre code {
  background: transparent;
  color: inherit;
  padding: 0;
}

.preview blockquote {
  border-left: 4px solid var(--accent);
  color: #405058;
  background: rgba(239, 246, 255, 0.72);
  padding: 10px 14px;
}

.preview .code-fallback {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.preview .inline-code-fallback {
  border-radius: 6px;
  background: var(--code);
  padding: 2px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
}

.preview .text-divider {
  color: var(--muted);
  letter-spacing: 0;
  text-align: center;
}

.preview img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.asset-list {
  min-height: 570px;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start;
  gap: 14px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.asset-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-strong);
  box-shadow: var(--soft-shadow);
}

.asset-card img {
  display: block;
  width: 100%;
  height: 210px;
  object-fit: contain;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.asset-card footer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px;
}

.asset-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.asset-actions {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.asset-actions button {
  min-height: 32px;
  padding: 0 9px;
  border-radius: 12px;
  font-size: 12px;
  white-space: nowrap;
}

.asset-actions .copy-asset {
  border-color: rgba(10, 132, 255, 0.34);
  background: rgba(10, 132, 255, 0.09);
  color: #0066cc;
  font-weight: 650;
}

.asset-actions .copy-asset:hover {
  border-color: rgba(10, 132, 255, 0.58);
  background: rgba(10, 132, 255, 0.16);
  color: #004f9f;
}

.empty-state {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.56);
  padding: 24px;
  text-align: center;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  min-width: 220px;
  max-width: min(520px, calc(100vw - 32px));
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  padding: 11px 16px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  text-align: center;
  font-size: 14px;
  backdrop-filter: blur(18px);
}

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

@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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

  textarea,
  .tab-panel textarea,
  .preview,
  .asset-list {
    min-height: 420px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1520px);
    padding-top: 16px;
  }

  .topbar,
  .panel-header,
  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 32px;
  }

  .toolbar {
    justify-content: flex-start;
  }

  .tabbar {
    grid-template-columns: 1fr 1fr;
  }

  .asset-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  button {
    flex: 1 1 auto;
  }
}
