/* ==========================================================================
   学术自检 (Writing Check) — 高级通透版面 (Premium Glassmorphism)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  --bg-solid: #f1f5f9;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-soft: rgba(255, 255, 255, 0.6);
  --ink: #0f172a;
  --muted: #64748b;
  --line: rgba(203, 213, 225, 0.6);
  --primary: #4f46e5;
  --primary-deep: #4338ca;
  --amber: #d97706;
  --red: #dc2626;
  --shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.12);
  --shadow-sm: 0 8px 24px -4px rgba(15, 23, 42, 0.05);
  --border-radius: 16px;
  --card-radius: 24px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg-gradient);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.privacy-badge {
  font-size: 13px;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid rgba(79, 70, 229, 0.15);
}

/* App Shell */
.app-workspace {
  flex: 1;
  width: min(1440px, calc(100% - 48px));
  margin: 32px auto 48px;
  display: flex;
  flex-direction: column;
}

.workspace-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 32px;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .workspace-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
}

/* Panels */
.editor-panel,
.report-panel {
  background: var(--surface);
  backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow);
  padding: 32px;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.editor-panel:hover,
.report-panel:hover {
  box-shadow: 0 32px 64px -12px rgba(15, 23, 42, 0.14);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}

.panel-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* View Toggle */
.view-toggle {
  display: flex;
  background: rgba(241, 245, 249, 0.8);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
}

.view-toggle .toggle-btn {
  background: transparent;
  border: none;
  height: 32px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-toggle .toggle-btn:hover {
  color: var(--ink);
}

.view-toggle .toggle-btn.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.clear-button {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  padding: 0 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.clear-button:hover {
  color: var(--red);
  background: rgba(220, 38, 38, 0.08);
}

/* Form elements */
.options-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.option-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.option-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.option-field select {
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.option-field select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* Input textareas */
.input-area-wrapper {
  position: relative;
  flex: 1;
  min-height: 420px;
  margin-bottom: 24px;
}

#paper-input,
.paper-markup-preview {
  width: 100%;
  height: 100%;
  min-height: 420px;
  padding: 24px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  outline: none;
  resize: vertical;
  transition: all 0.2s ease;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.02);
  font-family: inherit;
}

#paper-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  background: #fff;
}

.paper-markup-preview {
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--surface-soft);
}

.hidden {
  display: none !important;
}

/* Buttons */
.actions-bar {
  display: flex;
  gap: 16px;
}

.button {
  height: 48px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.01em;
}

.button--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-deep));
  color: #fff;
  flex: 1;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.25);
}

.button--primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.35);
}

.button--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.button--secondary {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  color: var(--ink);
}

.button--secondary:hover {
  background: #fff;
  border-color: var(--muted);
  box-shadow: var(--shadow-sm);
}

.button--small {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
}

.button--dark {
  background: var(--ink);
  color: #fff;
}

.button--dark:hover {
  background: #000;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Score section */
.status-indicator {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg-solid);
  padding: 6px 14px;
  border-radius: 8px;
}

.diagnostic-score-card {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.score-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 6px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
  transition: all 0.4s ease-out;
  background: #fff;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.score-meta h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.score-meta p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Results Content */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.report-section h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
  letter-spacing: 0.02em;
}

.signal-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.signal-list li {
  font-size: 14px;
  line-height: 1.6;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--surface-soft);
  border-left: 4px solid var(--primary);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.empty-placeholder {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  padding: 32px 24px;
  background: rgba(248, 250, 252, 0.5);
  border: 2px dashed var(--line);
  border-radius: 12px;
}

/* Suggestions & Modules */
.module-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.module-item {
  padding: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: all 0.2s;
}

.module-item:hover {
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.module-item strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.module-item p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Revised output */
.revised-section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 24px;
  margin-bottom: 8px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.revised-box {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  min-height: 180px;
  transition: all 0.3s ease;
}

.revised-box.is-loading {
  border-color: rgba(79, 70, 229, 0.35);
  background: rgba(79, 70, 229, 0.04);
}

.revised-box.is-error {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(220, 38, 38, 0.04);
}

.revised-placeholder {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.6;
}

.revised-output {
  font-size: 16px;
  line-height: 1.85;
  color: var(--ink);
  white-space: pre-wrap;
  word-wrap: break-word;
}

.revised-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Markup Tooltip styles */
.markup-tag {
  position: relative;
  border-bottom: 2px dashed var(--amber);
  cursor: help;
  background-color: rgba(217, 119, 6, 0.1);
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 500;
  transition: background-color 0.2s;
}

.markup-tag:hover {
  background-color: rgba(217, 119, 6, 0.2);
}

.markup-tag::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 135%;
  left: 50%;
  transform: translateX(-50%) scale(0.95);
  background-color: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.markup-tag:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* Toast alert */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: 0 12px 24px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 9999;
}

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

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.footer-container {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.footer-container a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.footer-container a:hover {
  color: var(--primary);
}
