/* ============================================================
   CalmWorkspace — themes, layout, desktop-first UI
   ============================================================ */

/* ---- Light default ---- */
:root,
[data-theme="light-default"] {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f9fafb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-soft: #eef0f3;
  --accent: #4a7c9b;
  --accent-hover: #3d6a85;
  --accent-soft: #e8f1f6;
  --highlight-bg: #fef9e7;
  --highlight-underline: #d4a84b;
  --danger: #b45353;
  --danger-soft: #fdf2f2;
  --warning-text: #8a6d3b;
  --warning-bg: #fffbeb;
  --warning-border: #f0e0a8;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
  --scrollbar: #d1d5db;
  --scrollbar-hover: #9ca3af;
  --toast-bg: #1f2937;
  --toast-text: #fff;
}

/* ---- Soft light (low contrast, easy on eyes) ---- */
[data-theme="light-soft"] {
  --bg: #eef1f4;
  --surface: #f8f9fb;
  --surface-muted: #f1f3f6;
  --text: #3d4550;
  --text-muted: #7a8490;
  --text-light: #a3abb5;
  --border: #dde2e8;
  --border-soft: #e8ecf0;
  --accent: #5b8ba8;
  --accent-hover: #4d7a94;
  --accent-soft: #e4eef3;
  --highlight-bg: #f8f4e8;
  --highlight-underline: #c9b87a;
  --danger: #a86b6b;
  --danger-soft: #faf4f4;
  --warning-text: #7d6a45;
  --warning-bg: #faf6eb;
  --warning-border: #e8dfc8;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 3px 12px rgba(15, 23, 42, 0.05);
  --scrollbar: #c8cfd6;
  --scrollbar-hover: #a8b0b8;
  --toast-bg: #3d4550;
  --toast-text: #f8f9fb;
}

/* ---- Warm light (cream paper) ---- */
[data-theme="light-warm"] {
  --bg: #f5f0e8;
  --surface: #faf7f2;
  --surface-muted: #f3ede4;
  --text: #3a342c;
  --text-muted: #6f6558;
  --text-light: #9a8f80;
  --border: #e5ddd0;
  --border-soft: #ede6da;
  --accent: #6d8f7a;
  --accent-hover: #5a7a66;
  --accent-soft: #e8f0eb;
  --highlight-bg: #faf0d8;
  --highlight-underline: #c4a86a;
  --danger: #a86b5c;
  --danger-soft: #faf3f0;
  --warning-text: #8a6d3b;
  --warning-bg: #faf5e8;
  --warning-border: #e8dcc0;
  --shadow-sm: 0 1px 3px rgba(58, 52, 44, 0.06);
  --shadow-md: 0 4px 14px rgba(58, 52, 44, 0.07);
  --scrollbar: #d4ccc0;
  --scrollbar-hover: #b0a898;
  --toast-bg: #3a342c;
  --toast-text: #faf7f2;
}

/* ---- Sepia (reading mode) ---- */
[data-theme="light-sepia"] {
  --bg: #ebe4d6;
  --surface: #f4efe4;
  --surface-muted: #ece5d8;
  --text: #3c352a;
  --text-muted: #6a5f4e;
  --text-light: #948a78;
  --border: #d8cfc0;
  --border-soft: #e2d9ca;
  --accent: #7a6b52;
  --accent-hover: #655845;
  --accent-soft: #ebe4d8;
  --highlight-bg: #f5e8c8;
  --highlight-underline: #b89858;
  --danger: #9a6b58;
  --danger-soft: #f8f0ec;
  --warning-text: #7a6340;
  --warning-bg: #f5edd8;
  --warning-border: #ddd0b0;
  --shadow-sm: 0 1px 3px rgba(60, 53, 42, 0.07);
  --shadow-md: 0 4px 14px rgba(60, 53, 42, 0.08);
  --scrollbar: #c8bfb0;
  --scrollbar-hover: #a89888;
  --toast-bg: #3c352a;
  --toast-text: #f4efe4;
}

[data-theme="light-ocean"] {
  --bg: #eef6f8;
  --surface: #f8fcfd;
  --surface-muted: #e8f4f6;
  --text: #1e3a42;
  --text-muted: #5a7a82;
  --text-light: #8aa8b0;
  --border: #cce0e6;
  --border-soft: #dceef2;
  --accent: #2a8a9b;
  --accent-hover: #237a89;
  --accent-soft: #d8f0f4;
  --highlight-bg: #fef8e8;
  --highlight-underline: #c9a858;
  --danger: #c46b6b;
  --danger-soft: #fdf2f2;
  --warning-text: #7a6a3b;
  --warning-bg: #fefae8;
  --warning-border: #e8e0b8;
  --shadow-sm: 0 1px 3px rgba(30, 58, 66, 0.06);
  --shadow-md: 0 4px 14px rgba(30, 58, 66, 0.08);
  --scrollbar: #b8d0d8;
  --scrollbar-hover: #8aa8b0;
  --toast-bg: #1e3a42;
  --toast-text: #f8fcfd;
}

[data-theme="light-forest"] {
  --bg: #eef4ef;
  --surface: #f8fbf8;
  --surface-muted: #e8f0ea;
  --text: #2a3d30;
  --text-muted: #5a7260;
  --text-light: #8aa090;
  --border: #cce0d4;
  --border-soft: #dceee4;
  --accent: #3d8a5c;
  --accent-hover: #347a4e;
  --accent-soft: #dff0e6;
  --highlight-bg: #f8f4e0;
  --highlight-underline: #b8a050;
  --danger: #b86a5a;
  --danger-soft: #fdf4f2;
  --warning-text: #6a6a30;
  --warning-bg: #f8f6e0;
  --warning-border: #e0dcb0;
  --shadow-sm: 0 1px 3px rgba(42, 61, 48, 0.06);
  --shadow-md: 0 4px 14px rgba(42, 61, 48, 0.08);
  --scrollbar: #b8d0c0;
  --scrollbar-hover: #8aa890;
  --toast-bg: #2a3d30;
  --toast-text: #f8fbf8;
}

[data-theme="light-rose"] {
  --bg: #faf2f4;
  --surface: #fffbfc;
  --surface-muted: #f8eef0;
  --text: #3d2a32;
  --text-muted: #7a5a64;
  --text-light: #a88a94;
  --border: #ecd8de;
  --border-soft: #f4e8ec;
  --accent: #c45a78;
  --accent-hover: #b04a68;
  --accent-soft: #fce8ee;
  --highlight-bg: #fef6e8;
  --highlight-underline: #d0a060;
  --danger: #c45050;
  --danger-soft: #fdf0f0;
  --warning-text: #8a6040;
  --warning-bg: #fef8ec;
  --warning-border: #ecd8c0;
  --shadow-sm: 0 1px 3px rgba(61, 42, 50, 0.06);
  --shadow-md: 0 4px 14px rgba(61, 42, 50, 0.08);
  --scrollbar: #e0c8d0;
  --scrollbar-hover: #c0a0a8;
  --toast-bg: #3d2a32;
  --toast-text: #fffbfc;
}

[data-theme="light-lavender"] {
  --bg: #f2f0f8;
  --surface: #faf9fd;
  --surface-muted: #ece8f4;
  --text: #322e42;
  --text-muted: #6a6480;
  --text-light: #9a94a8;
  --border: #dcd4ec;
  --border-soft: #e8e4f2;
  --accent: #7a5cb8;
  --accent-hover: #6a4ca8;
  --accent-soft: #ece4f8;
  --highlight-bg: #f8f4e8;
  --highlight-underline: #c0a058;
  --danger: #b86a78;
  --danger-soft: #fdf2f4;
  --warning-text: #7a6840;
  --warning-bg: #f8f4e8;
  --warning-border: #e0d8c0;
  --shadow-sm: 0 1px 3px rgba(50, 46, 66, 0.06);
  --shadow-md: 0 4px 14px rgba(50, 46, 66, 0.08);
  --scrollbar: #ccc4dc;
  --scrollbar-hover: #a8a0b8;
  --toast-bg: #322e42;
  --toast-text: #faf9fd;
}

[data-theme="light-slate"] {
  --bg: #eceef2;
  --surface: #f6f7f9;
  --surface-muted: #e4e6ea;
  --text: #2c3340;
  --text-muted: #5c6470;
  --text-light: #8c94a0;
  --border: #ccd0d8;
  --border-soft: #dce0e6;
  --accent: #506080;
  --accent-hover: #445470;
  --accent-soft: #e0e6ee;
  --highlight-bg: #f4f0e4;
  --highlight-underline: #b0a060;
  --danger: #a86060;
  --danger-soft: #f4ecec;
  --warning-text: #706040;
  --warning-bg: #f4f0e4;
  --warning-border: #d8d0c0;
  --shadow-sm: 0 1px 3px rgba(44, 51, 64, 0.06);
  --shadow-md: 0 4px 14px rgba(44, 51, 64, 0.08);
  --scrollbar: #b8bcc4;
  --scrollbar-hover: #989ca4;
  --toast-bg: #2c3340;
  --toast-text: #f6f7f9;
}

/* ---- Dark mode ---- */
[data-theme="dark"] {
  --bg: #16181c;
  --surface: #1e2128;
  --surface-muted: #252930;
  --text: #e2e4e9;
  --text-muted: #9aa3b0;
  --text-light: #6b7585;
  --border: #2e333d;
  --border-soft: #262b34;
  --accent: #6ba3c4;
  --accent-hover: #5a92b3;
  --accent-soft: #243442;
  --highlight-bg: #3a3528;
  --highlight-underline: #a88848;
  --danger: #c47a7a;
  --danger-soft: #2e2222;
  --warning-text: #c9b070;
  --warning-bg: #2e2a22;
  --warning-border: #4a4435;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --scrollbar: #3a404a;
  --scrollbar-hover: #505868;
  --toast-bg: #e2e4e9;
  --toast-text: #16181c;
}

:root {
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --sidebar-width: 240px;
  --header-height: 72px;
  --min-app-width: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app {
  min-width: var(--min-app-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: var(--header-height);
}

.header-left {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  line-height: 1.15;
}

.brand-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-wordmark {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-editor {
  color: #0f172a;
}

.brand-pilot {
  color: #2563eb;
}

.brand-tagline {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 0.76rem;
  font-weight: 400;
  color: #475569;
  letter-spacing: 0.01em;
}

html[data-theme="dark"] .brand-editor {
  color: #f1f5f9;
}

html[data-theme="dark"] .brand-pilot {
  color: #60a5fa;
}

html[data-theme="dark"] .brand-tagline {
  color: #94a3b8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.theme-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}

.theme-select,
.mode-select {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-select:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-icon {
  min-width: 34px;
  padding: 6px 10px !important;
}

.icon-dark {
  font-size: 1rem;
  line-height: 1;
}

#btn-dark-toggle[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.theme-toggle .icon-moon-group {
  display: block;
}

.theme-toggle .icon-sun-group {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon-group {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun-group {
  display: block;
}

.icon-sun-moon {
  display: block;
}

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

.model-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 6px 12px;
  background: var(--surface-muted);
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-select-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.model-select {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  max-width: 160px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-light);
  flex-shrink: 0;
}

.status-dot.ready { background: #5a9a6e; }
.status-dot.loading { background: #c9a227; animation: pulse 1.2s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  overflow-y: auto;
}

.sidebar-title {
  margin: 0 0 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.drafts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.empty-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-light);
  line-height: 1.45;
}

.draft-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  color: inherit;
}

.draft-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.draft-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.draft-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.draft-meta {
  display: block;
  font-size: 0.72rem;
  color: var(--text-light);
}

.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px 28px;
  gap: 14px;
  min-width: 0;
  overflow: hidden;
}

.mode-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-group-style {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(100%, 780px);
}

.mode-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.mode-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.mode-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.mode-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mode-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
  font-weight: 500;
}

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

.action-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.doc-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-sep {
  color: var(--text-light);
}

.checking-indicator {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

.score-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.score-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.score-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 2px;
}

.score-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-hover);
}

.score-value.score-good { color: #4a8f65; }
.score-value.score-mid { color: #b08a3a; }
.score-value.score-low { color: var(--danger); }

.length-warning {
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--warning-text);
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
}

.btn {
  padding: 8px 16px;
  font-size: 0.86rem;
  font-family: inherit;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:hover {
  background: var(--surface-muted);
  border-color: var(--text-light);
}

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

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

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

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 6px 12px;
}

.btn-ghost:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger-ghost {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
  font-size: 0.8rem;
  padding: 6px 12px;
  opacity: 0.85;
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
  opacity: 1;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ---- Panels: two columns ---- */

.panels {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
  transition: grid-template-columns 0.35s ease, gap 0.35s ease;
}

.panel-side {
  display: flex;
  flex-direction: column;
}

.panel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-lang-select {
  max-width: 148px;
  font-size: 0.78rem;
}

.panel-lang-select option.lang-tier-hint {
  font-style: italic;
  color: var(--text-light);
}

.panel-update-body {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}

.panel-fixing[hidden] {
  display: none !important;
}

.panel-fixing {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: color-mix(in srgb, var(--surface-muted) 88%, transparent);
  backdrop-filter: blur(2px);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
  pointer-events: none;
}

.panel-fixing-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: panel-fixing-spin 0.75s linear infinite;
}

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

.panel-fixing-dots span {
  animation: panel-fixing-dot 1.2s infinite;
  opacity: 0.25;
}

.panel-fixing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.panel-fixing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes panel-fixing-dot {
  0%,
  80%,
  100% {
    opacity: 0.25;
  }
  40% {
    opacity: 1;
  }
}

.panel-update-body .corrected-output {
  flex: 1;
  min-height: 360px;
}

.focus-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ---- Focus mode ---- */

.app.focus-mode .header,
.app.focus-mode .site-footer,
.app.focus-mode .mode-bar,
.app.focus-mode .action-bar,
.app.focus-mode .length-warning {
  opacity: 0.18;
  filter: brightness(0.75);
  pointer-events: none;
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.app.focus-mode .main-layout {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.5vmin, 32px);
  box-sizing: border-box;
  pointer-events: none;
  min-height: 0;
}

.app.focus-mode .workspace {
  pointer-events: auto;
  width: min(1400px, 96vw);
  height: min(90dvh, calc(100dvh - 2 * clamp(12px, 2.5vmin, 32px)));
  max-height: 90dvh;
  padding: 0;
  margin: 0;
  flex: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app.focus-mode .panels {
  display: grid;
  grid-template-columns: 1fr !important;
  flex: 1;
  min-height: 0;
  height: 100%;
  gap: 0;
  padding: 0;
  align-items: stretch;
  justify-items: stretch;
}

.app.focus-mode .panel-write {
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.24);
}

.app.focus-mode .panel-write .editor-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.app.focus-mode .panel-write .editor {
  flex: 1;
  min-height: 0;
}

.app.focus-mode .panel-update {
  display: none !important;
}

.app.focus-mode .donate-fab {
  opacity: 0.15;
  pointer-events: none;
}

.app.focus-mode::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  pointer-events: none;
  z-index: 5;
  transition: opacity 0.35s ease;
}

html[data-theme="dark"] .app.focus-mode::after {
  background: rgba(0, 0, 0, 0.55);
}

.corrected-output .diff-changed {
  background: rgba(250, 204, 21, 0.35);
  border-radius: 2px;
  padding: 0 1px;
}

.corrected-output .diff-added {
  background: rgba(74, 222, 128, 0.28);
  border-radius: 2px;
  padding: 0 1px;
}

#btn-compare.active,
#btn-compare[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.shortcuts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.shortcuts-table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

.shortcuts-table td:first-child {
  width: 42%;
  white-space: nowrap;
  color: var(--text);
}

.shortcuts-table td:last-child {
  color: var(--text-muted);
}

.shortcuts-table kbd,
.legal-body kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 0.78rem;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 0 var(--border);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  min-height: 480px;
  overflow: hidden;
}

.panel-write {
  min-height: 420px;
}

.panel-header-write {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.write-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.format-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.format-select {
  font-family: inherit;
  font-size: 0.78rem;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.format-btn {
  min-width: 32px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.format-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.format-btn:hover {
  background: var(--surface-muted);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.panel-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.panel-hint {
  font-size: 0.76rem;
  color: var(--text-light);
}

.panel-hint-block {
  margin: 0;
  padding: 0 20px 8px;
}

.editor-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.plain-text-sync {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
  left: -9999px;
}

.editor {
  flex: 1;
  min-height: 420px;
  padding: 22px 26px;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--text);
  outline: none;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  direction: ltr;
  unicode-bidi: plaintext;
  text-align: left;
}

.panels.ai-collapsed .editor {
  min-height: calc(100vh - 280px);
}

.editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  pointer-events: none;
}

.grammar-issue {
  background: var(--highlight-bg);
  border-bottom: 2px solid var(--highlight-underline);
  border-radius: 2px;
  cursor: pointer;
}

.grammar-issue:hover,
.grammar-issue.active {
  filter: brightness(0.97);
}

.corrected-output {
  flex: 1;
  min-height: 360px;
  padding: 18px 20px;
  font-size: 1rem;
  line-height: 1.7;
  overflow-y: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--surface-muted);
}

.corrected-output.empty {
  color: var(--text-light);
  font-style: italic;
}

.issue-popup {
  position: fixed;
  z-index: 1000;
  width: 300px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.issue-original {
  margin: 0 0 6px;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.issue-original::before {
  content: "Original: ";
  font-weight: 500;
}

.issue-suggestion {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--accent-hover);
}

.issue-explanation {
  margin: 0 0 12px;
  font-size: 0.8rem;
  color: var(--text-light);
}

.issue-actions {
  display: flex;
  gap: 8px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 0.86rem;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  z-index: 1100;
}

.editor::-webkit-scrollbar,
.corrected-output::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.rewrite-options::-webkit-scrollbar,
.rewrite-option-body::-webkit-scrollbar {
  width: 6px;
}

.editor::-webkit-scrollbar-thumb,
.corrected-output::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.rewrite-options::-webkit-scrollbar-thumb,
.rewrite-option-body::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 3px;
}

.draft-item-wrap {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.draft-item-wrap .draft-item {
  flex: 1;
  min-width: 0;
}

.draft-delete {
  flex-shrink: 0;
  width: 32px;
  padding: 0;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.draft-delete:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* ---- Modals ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 440px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.modal-setup {
  max-width: 520px;
}

.modal-title {
  margin: 0 0 10px;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-message {
  margin: 0 0 20px;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions .btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.modal-actions .btn-danger:hover {
  filter: brightness(0.92);
}

.setup-progress {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.setup-body {
  margin-bottom: 20px;
}

.setup-field {
  margin-bottom: 16px;
}

.setup-field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.setup-field select,
.setup-field .setup-options {
  width: 100%;
}

.setup-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-options-split {
  flex-direction: row;
  gap: 12px;
}

.setup-options-split .setup-option {
  flex: 1;
  min-width: 0;
}

.setup-field-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.setup-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.setup-option:hover {
  border-color: var(--accent);
}

.setup-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.setup-option strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.setup-option span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.setup-guide-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.setup-guide-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.setup-guide-list li:last-child {
  border-bottom: none;
}

.setup-guide-list strong {
  color: var(--text);
}

.setup-actions {
  justify-content: space-between;
}

.editor::-webkit-scrollbar-thumb:hover,
.corrected-output::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.rewrite-options::-webkit-scrollbar-thumb:hover,
.rewrite-option-body::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* ---- Footer ---- */

.site-footer {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  text-align: center;
}

.footer-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.footer-link {
  background: none;
  border: none;
  padding: 4px 8px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.footer-link:hover {
  color: var(--accent-hover);
}

.footer-sep {
  color: var(--text-light);
  font-size: 0.82rem;
}

.footer-copy {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-light);
}

.footer-site-link {
  color: var(--accent);
  text-decoration: none;
}

.footer-site-link:hover {
  text-decoration: underline;
}

.legal-body {
  max-height: 50vh;
  overflow-y: auto;
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.legal-body h3 {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  color: var(--text);
}

.legal-body p {
  margin: 0 0 10px;
}

/* ---- Donation ---- */

.donate-fab {
  position: fixed;
  left: 20px;
  bottom: 20px;
  z-index: 1500;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #1e40af;
  background: linear-gradient(145deg, #3b82f6 0%, #1d4ed8 55%, #2563eb 100%);
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(29, 78, 216, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donate-fab-icon {
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.donate-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(29, 78, 216, 0.6);
}

/* ---- Offline install hint ---- */

.offline-hint {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1500;
  width: min(280px, calc(100vw - 40px));
  padding: 14px 36px 14px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.offline-hint-title {
  margin: 0 0 6px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.offline-hint-note {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-light);
}

.offline-hint-install {
  margin-top: 10px;
  width: 100%;
}

.offline-hint-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.offline-hint-close:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.app.focus-mode .offline-hint {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.donation-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.donation-modal .modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

.close-modal {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.donation-message {
  padding: 16px 20px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.donation-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px 16px;
}

.donation-link {
  display: block;
  padding: 10px 14px;
  text-align: center;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent-hover);
  background: var(--accent-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.donation-link:hover {
  background: var(--surface-muted);
}

.footnote {
  padding: 12px 20px 16px;
  font-size: 0.75rem;
  color: var(--text-light);
  border-top: 1px solid var(--border-soft);
  text-align: center;
}

/* ---- Rewrite modal ---- */

.modal-rewrite {
  max-width: 560px;
}

.rewrite-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 16px;
}

.rewrite-option {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-muted);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.15s;
}

.rewrite-option:hover {
  border-color: var(--accent);
}

.rewrite-option-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

.rewrite-option-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
}

.rewrite-option-body {
  flex: 1;
  min-height: 72px;
  max-height: 180px;
  padding: 12px 16px;
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-wrap: break-word;
}
