/* =============================================================
   Tomoshibi Web - styles.css
   ============================================================= */

/* ===== 0. Bundled Fonts ===== */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/cormorant-garamond-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/source-sans-3-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url('../fonts/source-sans-3-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ===== 1. Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
*:focus-visible {
  outline: 2px solid rgba(var(--accent-rgb), 0.5);
  outline-offset: 2px;
}
*:focus:not(:focus-visible) { outline: none; }
textarea:focus-visible, input:focus-visible { outline: none; }
textarea, input {
  border: none !important;
  -webkit-focus-ring-color: transparent !important;
  outline-offset: 0 !important;
}
html, body { height: 100%; width: 100%; }

/* ===== 2. CSS Custom Properties ===== */
body {
  --font-display: 'Cormorant Garamond', serif;
  --font-ui: 'Source Sans 3', sans-serif;
  --transition-speed: 0.3s;
  --transition-speed-slow: 0.5s;

  /* Base Colors (Theme: Flame - default) */
  --bg: #0a090c;
  --text-rgb: 255, 255, 255;
  --accent-rgb: 215, 185, 145;
  --danger-rgb: 255, 100, 100;
  --hint-rgb: 180, 150, 120;
  --prose-rgb: 235, 195, 125;
  --surface-hover: rgba(255, 255, 255, 0.03);
  --surface-active: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.1);
  --flame-core-start: rgba(255, 200, 150, 0.12);
  --flame-core-end: rgba(255, 180, 120, 0.06);
  --flame-inner-start: rgba(255, 180, 130, 0.08);
  --flame-inner-end: rgba(255, 150, 100, 0.04);
  --flame-outer-start: rgba(255, 160, 120, 0.05);
  --flame-outer-end: rgba(255, 140, 100, 0.025);
  --flame-glow-start: rgba(255, 150, 100, 0.04);
  --flame-glow-end: rgba(255, 130, 90, 0.02);
  --flame-display: block;

  font-family: var(--font-ui);
  background: var(--bg);
  color: #fff;
  min-height: 100vh;
  overflow: hidden;
  transition: background var(--transition-speed-slow), color var(--transition-speed-slow);
}

/* --- Theme: Plane --- */
body.plane {
  --bg: #faf9f7;
  --text-rgb: 0, 0, 0;
  --accent-rgb: 0, 0, 0;
  --danger-rgb: 200, 60, 60;
  --hint-rgb: 0, 0, 0;
  --prose-rgb: 51, 51, 51;
  --surface-hover: rgba(0, 0, 0, 0.025);
  --surface-active: rgba(0, 0, 0, 0.04);
  --border-subtle: rgba(0, 0, 0, 0.1);
  --border-medium: rgba(0, 0, 0, 0.12);
  --flame-display: none;
  color: #222;
}

/* --- Theme: Whiteout --- */
body.whiteout {
  --bg: #f3f4f6;
  --text-rgb: 0, 0, 0;
  --accent-rgb: 50, 70, 100;
  --danger-rgb: 180, 60, 60;
  --hint-rgb: 100, 120, 140;
  --prose-rgb: 100, 130, 170;
  --surface-hover: rgba(0, 0, 0, 0.03);
  --surface-active: rgba(0, 0, 0, 0.06);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-medium: rgba(0, 0, 0, 0.1);
  --flame-core-start: rgba(180, 200, 230, 0.12);
  --flame-core-end: rgba(160, 180, 210, 0.06);
  --flame-inner-start: rgba(160, 185, 220, 0.08);
  --flame-inner-end: rgba(140, 165, 200, 0.04);
  --flame-outer-start: rgba(150, 175, 210, 0.05);
  --flame-outer-end: rgba(130, 155, 190, 0.025);
  --flame-glow-start: rgba(140, 170, 210, 0.04);
  --flame-glow-end: rgba(120, 150, 190, 0.02);
  color: #333;
}

/* --- Theme: Dawn --- */
body.dawn {
  --bg: #1a1025;
  --text-rgb: 255, 255, 255;
  --accent-rgb: 255, 180, 200;
  --danger-rgb: 255, 100, 100;
  --hint-rgb: 200, 160, 180;
  --prose-rgb: 230, 175, 195;
  --surface-hover: rgba(255, 255, 255, 0.03);
  --surface-active: rgba(255, 255, 255, 0.06);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.1);
  --flame-core-start: rgba(255, 200, 220, 0.1);
  --flame-core-end: rgba(255, 180, 200, 0.05);
  --flame-inner-start: rgba(255, 180, 210, 0.07);
  --flame-inner-end: rgba(255, 150, 190, 0.035);
  --flame-outer-start: rgba(255, 160, 200, 0.045);
  --flame-outer-end: rgba(240, 140, 180, 0.02);
  --flame-glow-start: rgba(255, 150, 200, 0.035);
  --flame-glow-end: rgba(240, 130, 180, 0.015);
}

/* ===== 3. Screen Transition Foundation ===== */
.screen {
  position: fixed;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-speed) ease, visibility var(--transition-speed);
  z-index: 1;
  display: flex;
  overflow: hidden;
}
.screen.active {
  opacity: 1;
  visibility: visible;
  z-index: 2;
}

/* Write screen: slower, ceremonial */
#write-screen {
  transition: opacity 0.6s ease, visibility 0.6s;
}

/* ===== 4. Loading ===== */
#loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bg); z-index: 1000; transition: opacity 0.4s ease;
}
#loading.hidden { opacity: 0; pointer-events: none; }
#loading .loading-icon { width: 80px; height: 80px; margin-bottom: 12px; opacity: 0.85; }
#loading span {
  color: rgba(var(--accent-rgb), 0.5);
  font-family: var(--font-display);
  font-style: italic; font-size: 13px; letter-spacing: 1px;
}

/* ===== 5. Write Screen ===== */
#write-screen {
  position: fixed; overflow: hidden;
  height: 100vh; height: 100dvh;
  width: 100vw;
}

/* Flame ambient light */
.flame-container {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  pointer-events: none; z-index: 0;
}
.flame-core, .flame-inner, .flame-outer, .flame-glow {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); border-radius: 50%;
  will-change: opacity, transform;
  transition: transform 0.12s ease-out;
}
.flame-core {
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--flame-core-start) 0%, var(--flame-core-end) 40%, transparent 70%);
  filter: blur(40px);
}
.flame-inner {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--flame-inner-start) 0%, var(--flame-inner-end) 50%, transparent 70%);
  filter: blur(60px);
}
.flame-outer {
  width: 800px; height: 800px;
  background: radial-gradient(circle, var(--flame-outer-start) 0%, var(--flame-outer-end) 50%, transparent 70%);
  filter: blur(80px);
}
.flame-glow {
  width: 120vmax; height: 120vmax;
  background: radial-gradient(circle, var(--flame-glow-start) 0%, var(--flame-glow-end) 40%, transparent 60%);
  filter: blur(100px);
}
body.plane .flame-container { display: none; }

/* Flame breathing animation
   Performance: opacity-only animation avoids re-rasterizing blur layers.
   The translate(-50%, -50%) centering is handled by the base rule above,
   so keyframes touch only opacity (compositor-friendly). */
@keyframes flame-breathe {
  0% { opacity: 0.85; }
  25% { opacity: 0.95; }
  42% { opacity: 0.88; }
  58% { opacity: 1; }
  78% { opacity: 0.91; }
  100% { opacity: 0.85; }
}
@keyframes flame-breathe-inner {
  0% { opacity: 0.88; }
  30% { opacity: 0.97; }
  50% { opacity: 0.9; }
  72% { opacity: 1; }
  100% { opacity: 0.88; }
}
@keyframes flame-breathe-outer {
  0% { opacity: 0.9; }
  20% { opacity: 0.95; }
  45% { opacity: 0.88; }
  65% { opacity: 1; }
  85% { opacity: 0.92; }
  100% { opacity: 0.9; }
}

.flame-breathing .flame-core {
  animation: flame-breathe 4.2s ease-in-out infinite;
  will-change: opacity;
}
.flame-breathing .flame-inner {
  animation: flame-breathe-inner 5.7s ease-in-out infinite;
  will-change: opacity;
}
.flame-breathing .flame-outer {
  animation: flame-breathe-outer 7.3s ease-in-out infinite;
  will-change: opacity;
}

/* Confirmed chunks */
.confirmed-chunks {
  position: fixed; bottom: 50%; left: 50%; transform: translateX(-50%);
  z-index: 1; width: 100%; max-width: 520px; padding: 0 28px;
  margin-bottom: 18px; display: flex; flex-direction: column; justify-content: flex-end;
}
.chunk {
  font-family: var(--font-display);
  font-size: 17px; line-height: 2.1; letter-spacing: 0.4px;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: break-word;
  user-select: none; min-height: 1.2em;
}

/* Editor */
.input-area {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1; width: 100%; max-width: 520px; padding: 0 28px;
  border: none; outline: none; box-shadow: none; background: transparent;
}
#editor {
  width: 100%;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  outline-width: 0 !important;
  resize: none;
  box-shadow: none !important;
  -webkit-appearance: none !important;
  -webkit-box-shadow: none !important;
  -webkit-tap-highlight-color: transparent !important;
  -webkit-focus-ring-color: transparent !important;
  appearance: none !important;
  font-family: var(--font-display);
  font-size: 17px; line-height: 2.1; letter-spacing: 0.4px;
  overflow-wrap: break-word; word-break: break-word; overflow: hidden;
  color: rgba(var(--prose-rgb), 0.95);
  caret-color: rgb(var(--prose-rgb));
}
#editor:focus,
#editor:focus-visible,
#editor:focus-within {
  outline: none !important; outline-width: 0 !important;
  border: none !important; box-shadow: none !important;
  -webkit-box-shadow: none !important;
  -webkit-focus-ring-color: transparent !important;
  background: transparent !important;
}
#editor::spelling-error,
#editor::grammar-error { text-decoration: none; }
#editor::-webkit-input-placeholder { color: rgba(var(--prose-rgb), 0.3); }
#editor::placeholder { color: rgba(var(--prose-rgb), 0.3); }

/* Write hint (gear button area) */
.write-hint {
  position: fixed; bottom: 22px; left: 24px;
  text-align: left; z-index: 1;
  font-family: var(--font-display);
  font-size: 11px; font-style: italic; letter-spacing: 1px;
  color: rgba(var(--hint-rgb), 0.15);
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
.write-hint.visible { opacity: 1; pointer-events: auto; }

/* Gear button (settings trigger) — always visible, top-left */
.web-settings-btn {
  position: fixed; top: 20px; left: 22px;
  z-index: 10;
  background: none; border: none;
  color: rgba(var(--hint-rgb), 0.35);
  cursor: pointer; padding: 4px;
  transition: color 0.2s;
  line-height: 0;
}
.web-settings-btn:hover { color: rgba(var(--hint-rgb), 0.7); }
.web-settings-btn svg { width: 18px; height: 18px; }

/* App promo (right bottom) */
.app-promo {
  position: fixed; bottom: 22px; right: 24px;
  z-index: 10;
  font-family: var(--font-display);
  font-size: 11px; font-style: italic; letter-spacing: 0.5px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s ease;
}
.app-promo.visible { opacity: 1; pointer-events: auto; }
.app-promo a {
  color: rgba(var(--hint-rgb), 0.15);
  text-decoration: none;
  transition: color 0.2s;
}
.app-promo a:hover { color: rgba(var(--hint-rgb), 0.5); }

/* ===== 6. Settings Overlay ===== */
.settings-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.settings-overlay.active {
  display: flex;
}
.settings-panel {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}
.settings-close-btn {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  color: rgba(var(--text-rgb), 0.3);
  cursor: pointer; padding: 4px;
  transition: color 0.2s;
  line-height: 0;
}
.settings-close-btn:hover { color: rgba(var(--text-rgb), 0.6); }
.settings-close-btn svg { width: 16px; height: 16px; }

/* Settings sections (reused from desktop) */
.settings-section { margin-bottom: 32px; }
.settings-label {
  color: rgba(var(--text-rgb), 0.4);
  font-size: 11px; letter-spacing: 1.5px; margin-bottom: 14px; text-transform: uppercase;
}

/* Mode options */
.mode-options { display: flex; gap: 10px; }
.mode-option {
  background: var(--surface-hover);
  border: 1px solid var(--border-subtle);
  flex: 1; border-radius: 10px; padding: 14px 12px; text-align: center;
  cursor: pointer; transition: all 0.2s;
}
.mode-option:hover {
  background: var(--surface-active);
  border-color: rgba(var(--text-rgb), 0.15);
}
.mode-option.active {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
}
.mode-option-name { color: rgba(var(--text-rgb), 0.7); font-size: 13px; margin-bottom: 4px; }
.mode-option.active .mode-option-name { color: rgba(var(--accent-rgb), 0.9); }
.mode-option-desc { color: rgba(var(--text-rgb), 0.3); font-size: 10px; }

/* Toggle */
.toggle-setting { display: flex; align-items: center; gap: 12px; }
.toggle-label { color: rgba(var(--accent-rgb), 0.7); font-size: 14px; min-width: 30px; }
.toggle-btn {
  width: 50px; height: 28px; border-radius: 14px; border: none;
  background: rgba(var(--text-rgb), 0.1);
  cursor: pointer; position: relative; transition: background var(--transition-speed);
}
.toggle-btn.active { background: rgba(var(--accent-rgb), 0.4); }
.toggle-knob {
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(var(--text-rgb), 0.6);
  transition: transform var(--transition-speed), background var(--transition-speed);
}
.toggle-btn.active .toggle-knob {
  transform: translateX(22px);
  background: rgba(var(--accent-rgb), 0.9);
}

/* Width setting */
.width-setting { display: flex; flex-direction: column; gap: 12px; }
.width-display { display: flex; justify-content: space-between; align-items: baseline; }
.width-value {
  color: rgba(var(--accent-rgb), 0.8);
  font-size: 28px; font-family: var(--font-display);
}
.width-unit { color: rgba(var(--text-rgb), 0.35); font-size: 12px; }
.width-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 4px;
  background: rgba(var(--text-rgb), 0.1);
  border-radius: 2px; outline: none; cursor: pointer;
}
.width-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px;
  background: rgba(var(--accent-rgb), 0.6);
  border-radius: 50%; cursor: pointer; transition: background 0.2s;
}
.width-slider::-webkit-slider-thumb:hover { background: rgba(var(--accent-rgb), 0.9); }

/* Language options */
.language-options-inline { display: flex; gap: 8px; }
.lang-option {
  background: var(--surface-hover);
  border: 1px solid var(--border-subtle);
  border-radius: 8px; padding: 8px 16px;
  color: rgba(var(--text-rgb), 0.4);
  font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.lang-option:hover {
  background: var(--surface-active);
  color: rgba(var(--text-rgb), 0.6);
}
.lang-option.active {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: rgba(var(--accent-rgb), 0.9);
}

/* New session button */
.new-session-btn {
  width: 100%;
  background: transparent;
  border: 1px solid rgba(var(--text-rgb), 0.08);
  border-radius: 8px;
  padding: 10px 16px;
  color: rgba(var(--text-rgb), 0.3);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}
.new-session-btn:hover {
  background: rgba(var(--text-rgb), 0.03);
  border-color: rgba(var(--text-rgb), 0.15);
  color: rgba(var(--text-rgb), 0.5);
}

/* Read back button (right top) */
.read-back-btn {
  position: fixed; top: 20px; right: 22px;
  z-index: 10;
  background: none; border: none;
  color: rgba(var(--hint-rgb), 0.35);
  cursor: pointer;
  transition: color 0.3s, opacity 0.3s;
  display: flex; align-items: center; gap: 6px;
  opacity: 0; pointer-events: none;
}
.read-back-btn.visible { opacity: 1; pointer-events: auto; }
.read-back-btn:hover { color: rgba(var(--hint-rgb), 0.7); }
.read-back-btn svg { width: 16px; height: 16px; }
.read-back-btn .read-back-label {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12px;
  letter-spacing: 0.3px;
}

/* Read back overlay */
.read-overlay {
  position: fixed; inset: 0;
  z-index: 100;
  display: none;
  justify-content: center;
  align-items: flex-start;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.read-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, rgba(var(--prose-rgb), 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.read-overlay.active { display: flex; }

.read-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 600px;
  padding: 60px 32px 120px;
  min-height: 100vh;
}

.read-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 48px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(var(--text-rgb), 0.06);
}

.read-charcount {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 13px;
  color: rgba(var(--text-rgb), 0.3);
  letter-spacing: 0.5px;
}

.read-actions {
  display: flex; gap: 12px;
}

.read-share-btn {
  background: none;
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 8px;
  padding: 7px 14px 7px 11px;
  font-size: 12px;
  color: rgba(var(--accent-rgb), 0.7);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-display);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 5px;
}
.read-share-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.read-share-btn:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  color: rgba(var(--accent-rgb), 0.9);
  background: rgba(var(--accent-rgb), 0.05);
}

/* Share menu */
.share-menu-wrap {
  position: relative;
}
.share-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg);
  border: 1px solid rgba(var(--text-rgb), 0.1);
  border-radius: 10px;
  padding: 12px;
  min-width: 240px;
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  pointer-events: none;
}
.share-menu.active {
  visibility: visible;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Share preview */
.share-preview {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(var(--text-rgb), 0.5);
  padding: 8px 10px;
  background: rgba(var(--text-rgb), 0.03);
  border-radius: 6px;
  white-space: pre-line;
  margin-bottom: 6px;
}
.share-hint {
  font-size: 10px;
  color: rgba(var(--text-rgb), 0.25);
  padding: 0 2px 4px;
  letter-spacing: 0.3px;
}
.share-menu-divider {
  height: 1px;
  background: rgba(var(--text-rgb), 0.06);
  margin: 6px 0;
}

.share-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  padding: 8px 10px;
  font-size: 12px;
  color: rgba(var(--text-rgb), 0.6);
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
  transition: all 0.15s;
  font-family: var(--font-ui);
}
.share-menu-item:hover {
  background: rgba(var(--text-rgb), 0.05);
  color: rgba(var(--text-rgb), 0.9);
}
.share-menu-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.6;
}
.share-menu-sub {
  display: block;
  font-size: 10px;
  color: rgba(var(--text-rgb), 0.3);
  margin-top: 2px;
  letter-spacing: 0.2px;
}

.read-close-btn {
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  border-radius: 6px;
  padding: 6px 16px;
  font-size: 12px;
  color: rgba(var(--accent-rgb), 0.8);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-display);
  font-style: italic;
}
.read-close-btn:hover {
  background: rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.4);
}

.read-body {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 2.1;
  letter-spacing: 0.3px;
  color: rgba(var(--prose-rgb), 0.85);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* Save/Error toast */
.save-toast {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%);
  background: rgba(var(--accent-rgb), 0.15);
  color: rgba(var(--accent-rgb), 0.8);
  font-family: var(--font-display);
  font-size: 12px; font-style: italic;
  padding: 6px 16px; border-radius: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 50;
}
.save-toast.visible { opacity: 1; }

.error-toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(var(--danger-rgb), 0.15);
  color: rgba(var(--danger-rgb), 0.9);
  font-size: 12px;
  padding: 8px 16px; border-radius: 6px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 200;
}
.error-toast.visible { opacity: 1; }

/* ===== 7. Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 8. Mobile Responsive ===== */
@supports (height: 100dvh) {
  #write-screen { height: 100dvh; }
}

@media (max-width: 600px) {
  .confirmed-chunks { padding: 0 16px; }
  .input-area { padding: 0 16px; }

  .settings-panel {
    margin: 16px;
    padding: 24px;
    max-height: 90vh;
  }

  .mode-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .web-settings-btn { top: 16px; left: 16px; }
  .read-back-btn { top: 16px; right: 16px; }
  .app-promo { bottom: 16px; right: 16px; }

  .read-panel { padding: 40px 20px 100px; }

  /* Mobile bottom sheet for share menu */
  .share-menu {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    margin-top: 0;
    border-radius: 16px 16px 0 0;
    min-width: unset;
    width: 100%;
    padding: 20px 16px calc(env(safe-area-inset-bottom, 0px) + 16px);
    transform: translateY(100%);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.3);
  }
  .share-menu.active {
    transform: translateY(0);
  }

  /* Backdrop for mobile bottom sheet */
  .share-menu-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9;
    opacity: 0;
    transition: opacity 0.2s;
  }
  .share-menu-backdrop.active {
    display: block;
    opacity: 1;
  }
}
