:root {
  --bg: #FCFCFC;
  --page: #FCFCFC;
  --surface: #FFFFFF;
  --surface-2: #F0F0EE;
  --line: #E5E5E5;
  --line-strong: #D5D5D5;
  --border: #E5E5E5;
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --muted: #6E6E73;
  --accent: #007AFF;
  --accent-hover: #0066CC;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

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

input,
button,
textarea,
select {
  font-family: inherit;
}

[hidden],
button[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: #b4d5fe;
  color: inherit;
}

body {
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-rows: 56px 1fr;
  height: 100dvh;
}

.toolbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--page);
  border-bottom: 1px solid var(--line);
  color: var(--text);
  z-index: 10;
  min-width: 0;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.035em;
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
  user-select: none;
}

.brand-dot {
  color: #F4B942;
}

.icon-button {
  appearance: none;
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9999px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  font-family: var(--font);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
}

.icon-button svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 1.7;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.export-button {
  display: inline-flex;
  width: auto;
  gap: 7px;
  padding: 0 12px;
  font-size: 13px;
  white-space: nowrap;
}

.new-paper-btn {
  appearance: none;
  border: 1px solid var(--line);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.new-paper-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

.new-paper-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.help-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
}

.help-question-mark {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}

.help-button:hover .help-question-mark {
  color: var(--text);
}

.share-button svg {
  width: 16px;
  height: 16px;
}

.shared-cta-button {
  appearance: none;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--text);
  border-radius: 999px;
  background: var(--text);
  color: var(--surface);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.shared-cta-button:hover,
.shared-cta-button:focus-visible {
  background: #3A3A3C;
  outline: none;
  transform: translateY(-1px);
}

.shared-cta-button[hidden] {
  display: none;
}

/* WORKSPACE GRID */
.workspace {
  display: flex;
  height: 100%;
  overflow: hidden;
  background: var(--page);
}

.left-panel {
  width: 280px;
  flex: 0 0 280px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.suggestions-container {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
}

.suggestions-container .panel-body {
  flex: 1 1 0%;
  overflow-y: auto;
  padding: 16px;
}

.center-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--page);
}

.right-panel {
  width: 380px;
  flex: 0 0 380px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.right-panel.is-drag-review-target {
  box-shadow: inset 3px 0 0 var(--line-strong);
}

.right-panel.is-drag-review-over {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.right-panel.is-drag-review-unavailable {
  box-shadow: inset 3px 0 0 var(--line);
}

.right-view {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.right-view[hidden] {
  display: none !important;
}

/* Sidebar Nav */
.sidebar-nav {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding-left: 8px;
}

.nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--surface-2);
}

.nav-item.is-active {
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 500;
}

/* Common Panel Headers */
.panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

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

.panel-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.panel-body {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}

.shared-view-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  transform: translateX(-50%);
}

.shared-view-banner:hover,
.shared-view-banner:focus-visible {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  outline: none;
  transform: translateX(-50%) scale(1.02);
}

.shared-status-chip {
  flex: 0 1 auto;
  margin: 0 0 16px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
}

.shared-status-chip span {
  padding: 0 3px;
}

.shared-status-chip[hidden] {
  display: none;
}

.shared-view-banner[hidden] {
  display: none;
}

.notes-rail {
  background: linear-gradient(180deg, #f7f5f0, #f3f0e9);
  color: var(--text);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 0 10px;
  font-family: var(--font);
}

.notes-rail-header {
  padding: 4px 16px 12px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  font-family: var(--font);
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0 6px 6px;
  overflow: auto;
  min-height: 0;
}

.sidebar-notes-container {
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
  padding: 8px 0;
}

.sidebar-notes-container .note-list {
  height: 100%;
}

.note-item {
  display: block;
  width: 100%;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  line-height: 1.25;
  font-family: var(--font);
  position: relative;
}

.note-item:hover {
  background: var(--surface-2);
}

.note-item.active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

.note-item-title {
  display: block;
  padding-right: 56px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-delete-button {
  position: absolute;
  top: 8px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.note-item:hover .note-delete-button,
.note-delete-button:focus-visible {
  opacity: 1;
}

.note-delete-button:hover,
.note-delete-button:focus-visible {
  background: rgba(164, 71, 61, 0.08);
  color: #a4473d;
  outline: none;
}

.note-delete-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note-item.delete-confirming .note-edit-button {
  display: none;
}

.note-delete-confirm {
  position: absolute;
  top: 9px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(35, 33, 30, 0.07);
}

.note-delete-confirm button {
  appearance: none;
  border: 0;
  padding: 3px 7px;
  border-radius: 4px;
  background: transparent;
  font-family: var(--font);
  cursor: pointer;
}

.note-delete-yes {
  background: rgba(164, 71, 61, 0.1);
  color: #a4473d;
  font-weight: 600;
}

.note-delete-no {
  color: var(--muted);
}

.note-delete-confirm button:hover,
.note-delete-confirm button:focus-visible {
  outline: none;
}

.note-delete-yes:hover,
.note-delete-yes:focus-visible {
  background: rgba(164, 71, 61, 0.16);
}

.note-delete-no:hover,
.note-delete-no:focus-visible {
  background: var(--surface-2);
}

.note-title-input {
  display: block;
  width: 100%;
  border: 0;
  outline: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 0;
  font-family: var(--font);
  font-size: inherit;
  line-height: inherit;
}

.note-title-input:focus {
  box-shadow: inset 0 -1px var(--line-strong);
}

.note-edit-button {
  position: absolute;
  top: 11px;
  right: 39px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  appearance: none;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
}

.note-item:hover .note-edit-button,
.note-edit-button:focus {
  opacity: 1;
}

.note-edit-button:hover,
.note-edit-button:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.note-edit-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note-item-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--font);
}

.editor-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.editor-columns {
  display: flex;
  flex: 1;
  gap: 28px;
  min-height: 0;
  width: 100%;
}

.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  z-index: 100;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--text);
  color: var(--surface);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.app-toast:not([hidden]) {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.editor-column {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  min-width: 0;
  min-height: 0;
  position: relative;
  padding: 24px 32px 16px;
  background: var(--surface);
  border-radius: 0;
  -webkit-user-select: text;
  user-select: text;
}


.selection-toolbar {
  position: fixed;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: var(--muted);
  -webkit-user-select: none;
  user-select: none;
}

.selection-toolbar[hidden] {
  display: none;
}

.selection-toolbar button {
  display: grid;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.selection-toolbar button:hover,
.selection-toolbar button:focus-visible {
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}

.selection-toolbar button em {
  font-style: italic;
}

@media (pointer: coarse) {
  .editor-column {
    overflow: auto;
  }

  .editor {
    overflow: visible;
  }

  .selection-toolbar {
    position: sticky;
    top: 0;
    inset-inline: 0;
    z-index: 50;
    width: 100%;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 0;
    box-shadow: 0 -3px 10px rgba(112, 75, 48, 0.08);
  }

  .selection-toolbar button {
    min-width: 44px;
    min-height: 44px;
    font-size: 17px;
  }
}

.editor-topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 32px 12px;
  flex-shrink: 0;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.editor-title {
  appearance: none;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0;
  font-family: var(--font);
  color: var(--text);
  flex: 1 1 auto;
  width: auto;
  margin: 0 0 16px;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.editor-title:focus {
  outline: none;
  box-shadow: none;
}

.clear-sample-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  margin: 0 0 16px;
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: #c25343;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0.88;
  transition: opacity 0.16s ease, text-decoration-color 0.16s ease;
}

.clear-sample-button:hover,
.clear-sample-button:focus-visible {
  color: #a94437;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
  opacity: 1;
  outline: none;
}

.clear-sample-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.clear-sample-button[hidden] {
  display: none;
}

.editor-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  flex-shrink: 0;
}

.editor-topbar-actions .checkpoint-button,
.editor-topbar-actions .clear-sample-button,
.editor-topbar-actions .preview-note-button {
  margin-bottom: 0;
}

.preview-note-button,
.preview-secondary-button,
.preview-primary-button,
.review-prepare-button {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.preview-note-button {
  height: 34px;
  padding: 0 12px;
}

.preview-note-button:hover,
.preview-secondary-button:hover {
  background: var(--surface-2);
}

.markdown-preview[hidden],
.preview-note-button[hidden],
.review-prepare-button[hidden] {
  display: none !important;
}

.center-panel.is-previewing > .editor-topbar,
.center-panel.is-previewing > .editor-column {
  display: none;
}

.markdown-preview {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 30px 40px 40px;
  background: var(--page);
}

.markdown-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.markdown-preview-eyebrow,
.review-modal-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.markdown-preview h2,
.review-modal h2 {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-weight: 600;
}

.markdown-preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-secondary-button,
.preview-primary-button,
.review-prepare-button {
  min-height: 36px;
  padding: 0 14px;
}

.preview-primary-button,
.review-prepare-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.preview-primary-button:hover,
.review-prepare-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.markdown-preview-content {
  flex: 1 1 0%;
  min-height: 0;
  margin: 0;
  padding: 28px 32px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mobile-review-button {
  display: none;
}

.checkpoint-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  margin: 0 0 16px;
  padding: 5px 10px;
  border: 1px solid #3A3A3C;
  border-radius: 6px;
  background: #3A3A3C;
  color: #FFFFFF;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s ease;
}

.checkpoint-button:hover,
.checkpoint-button:focus-visible {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
  outline: none;
}

.checkpoint-button svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.checkpoint-button[hidden] {
  display: none;
}

.editor {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  background: transparent;
  padding: 0 1.5rem 40px;
  min-height: 0;
  overflow: auto;
  font-family: var(--font);
  -webkit-user-select: text;
  user-select: text;
  -webkit-tap-highlight-color: transparent;
}

.editor:focus {
  outline: none;
}

/* External block reorder controls; never participate in editable layout. */
.block-drag-handle {
  position: fixed;
  z-index: 25;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font-size: 20px;
  line-height: 24px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.block-drag-handle:hover { background: var(--surface-2); }
.block-drag-handle[data-state="dragging"] { cursor: grabbing; }
.block-drag-handle[data-state="invalid"] { cursor: not-allowed; }
.block-drop-indicator {
  position: fixed;
  z-index: 24;
  height: 0;
  border-top: 2px solid var(--text);
  pointer-events: none;
  user-select: none;
}
.block-drop-indicator[data-state="noop"] {
  border-top: 2px dashed var(--muted);
  opacity: 0.5;
}
.block-drag-handle[hidden], .block-drop-indicator[hidden] { display: none; }

.editor-block {
  display: block;
  width: 100%;
  min-height: 27px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  overflow: visible;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  background: transparent;
  color: #111827;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.editor-block,
.editor-block * {
  font-family: var(--font) !important;
  color: #111827;
  -webkit-user-select: text;
  user-select: text;
}

.editor-block[data-block-type="prompt_title"] {
  margin-top: 28px;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.45;
}

.editor-block[data-block-type="prompt_title"]:first-child {
  margin-top: 0;
}

.editor-block[data-block-type="note"] {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.65;
}

.editor-block[data-placeholder]:empty::before {
  color: var(--muted);
  content: attr(data-placeholder);
  font-style: italic;
  font-weight: 300;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.editor-block strong,
.editor-block b {
  font-weight: 700;
}

.editor-block em,
.editor-block i {
  font-style: italic;
}

.editor-block::placeholder {
  color: #aaa39b;
  font-style: italic;
  font-weight: 300;
}

.editor-block:focus {
  outline: 0;
}

.critique-panel {
  display: flex;
  flex: 0 0 380px;
  flex-direction: column;
  min-width: 280px;
  min-height: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--page);
}

.critique-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}

.critique-tabs {
  display: inline-flex;
  align-items: center;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  gap: 2px;
  padding: 2px;
  height: 32px;
  box-sizing: border-box;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  user-select: none;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.critique-tabs::-webkit-scrollbar {
  display: none;
}

.critique-tab {
  appearance: none;
  border: none;
  background: transparent;
  height: 100%;
  box-sizing: border-box;
  padding: 0 9px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.critique-tab:hover:not(.is-active) {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.critique-tab.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(90, 70, 50, 0.12);
}

.critique-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  background: rgba(0, 122, 255, 0.1);
  color: var(--accent);
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-badge[hidden] {
  display: none !important;
}

.critique-tab.is-active .tab-badge {
  background: rgba(0, 122, 255, 0.2);
  color: var(--accent);
}

/* Soft, muted light green background with darker green text for Resolved badge when resolved count > 0 */
.tab-badge.badge-resolved.has-resolved,
.tab-badge.has-resolved {
  background: var(--surface-2) !important;
  color: #2e693e !important;
}

.critique-tab.is-active .tab-badge.badge-resolved.has-resolved,
.critique-tab.is-active .tab-badge.has-resolved {
  background: #e2ede4 !important;
  color: #1a4d26 !important;
}

/* Muted warm amber background for Working badge when count > 0 */
.tab-badge.badge-working.has-working,
.tab-badge.has-working {
  background: var(--surface-2) !important;
  color: var(--muted) !important;
}

.critique-tab.is-active .tab-badge.badge-working.has-working,
.critique-tab.is-active .tab-badge.has-working {
  background: var(--line-strong) !important;
  color: var(--text) !important;
}

.feedback-run-button {
  flex: 0 0 auto;
  min-width: 62px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.feedback-run-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.feedback-run-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.feedback-run-button.is-loading::after {
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: review-spin 0.7s linear infinite;
}

.feedback-run-button:disabled,
.feedback-pill:disabled {
  cursor: wait;
  opacity: 0.72;
}

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

.critique-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.critique-title strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.critique-title span {
  color: var(--muted);
  font-size: 12px;
}

.critique-body {
  flex: 1;
  min-height: 0;
  padding: 24px;
  overflow: auto;
}

.critique-response {
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.critique-response.loading,
.critique-empty {
  color: var(--muted);
}

.critique-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  padding: 24px;
  text-align: center;
  font-size: 13px;
}

.diagnostic-sections {
  display: grid;
  gap: 20px;
}

.diagnostic-section {
  display: grid;
  gap: 7px;
}

.diagnostic-section strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.diagnostic-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.diagnostic-section-notice p {
  color: #d93025;
}

.suggestion-task-card,
.ai-question-pill,
.ai-task-pill {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  position: relative;
}

.suggestion-task-card:hover:not(.is-injected):not(.is-resolved) {
  background: var(--page);
  border-color: var(--line-strong);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

.suggestion-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}

.suggestion-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.thought-resolve-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 3px 8px 3px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  line-height: 1;
}

.thought-resolve-btn:hover {
  background: var(--line);
  color: var(--text);
}

.thought-resolve-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thought-resolve-icon {
  flex-shrink: 0;
  color: currentColor;
  transition: color 0.15s ease;
}

.thought-resolve-circle {
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.thought-resolve-check {
  opacity: 0;
  transform-origin: center;
  transition: opacity 0.15s ease, stroke 0.15s ease;
}

.thought-resolve-btn:hover .thought-resolve-check {
  opacity: 0.45;
}

/* Resolved state for button */
.thought-resolve-btn.is-resolved {
  background: #eaf4ec;
  border-color: #bad3c0;
  color: #2e693e;
}

.thought-resolve-btn.is-resolved .thought-resolve-icon {
  color: #2e693e;
}

.thought-resolve-btn.is-resolved .thought-resolve-circle {
  fill: #2e693e;
  stroke: #2e693e;
}

.thought-resolve-btn.is-resolved .thought-resolve-check {
  stroke: #ffffff;
  opacity: 1;
}

.thought-resolve-btn.is-resolved:hover {
  background: #e0eee3;
  border-color: #a7c6ad;
  color: #235230;
}

/* Card Working State */
.suggestion-tag.suggestion-tag-working {
  color: var(--muted);
}

.thought-attempt-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 3px 10px 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  margin-top: 2px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  line-height: 1;
}

.thought-attempt-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.thought-attempt-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thought-attempt-icon {
  flex-shrink: 0;
  color: currentColor;
}

.thought-reject-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 3px 8px 3px 6px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
  line-height: 1;
}

.thought-reject-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.thought-reject-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.thought-reject-icon {
  flex-shrink: 0;
  color: currentColor;
  transition: color 0.15s ease;
}

/* Card Resolved State */
.suggestion-task-card.is-resolved {
  background: var(--surface);
  border-color: var(--line);
  opacity: 0.7;
}

.suggestion-task-card.is-resolved .suggestion-tag {
  color: #2e693e;
}

.suggestion-task-card.is-resolved .suggestion-text {
  color: var(--muted) !important;
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}

/* Card Rejected State */
.suggestion-task-card.is-rejected {
  background: var(--surface);
  border-color: rgba(217, 48, 37, 0.25);
  opacity: 0.7;
}

.suggestion-tag.suggestion-tag-rejected {
  color: #d93025;
}

.thought-rejected-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  font-family: var(--font);
  font-size: 10.5px;
  font-weight: 500;
  color: #d93025;
  user-select: none;
  line-height: 1;
}

.thought-reject-badge-icon {
  flex-shrink: 0;
  color: currentColor;
}

.suggestion-text.suggestion-text-rejected {
  color: var(--muted) !important;
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
}

/* Resolving & Unresolving Card Animations */
.suggestion-task-card.is-resolving {
  opacity: 0;
  transform: translateX(14px);
  transition: opacity 0.26s ease, transform 0.26s ease;
}

.suggestion-task-card.is-resolving .thought-resolve-btn {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: #2e693e;
}

.suggestion-task-card.is-resolving .thought-resolve-circle {
  fill: #2e693e;
  stroke: #2e693e;
}

.suggestion-task-card.is-resolving .thought-resolve-check {
  opacity: 1;
  stroke: #ffffff;
}

.suggestion-task-card.is-resolving .suggestion-text {
  color: var(--muted) !important;
  text-decoration: line-through;
  text-decoration-color: var(--line-strong);
  transition: color 0.18s ease, text-decoration 0.18s ease;
}

.suggestion-task-card.is-unresolving {
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.critique-empty-state {
  padding: 38px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.critique-empty-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.critique-empty-desc {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  max-width: 260px;
  margin: 0 auto;
}

.suggestion-card-body {
  cursor: pointer;
  outline: none;
}

.suggestion-card-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.suggestion-text,
.ai-question-text,
.ai-task-text {
  font-weight: 500;
  color: #111827;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  transition: color 0.15s ease;
}

.suggestion-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.intent-judgment-controls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.intent-judgment-action[aria-pressed="true"] {
  border-color: var(--text-secondary);
  background: var(--line);
  color: var(--text);
}

.intent-correction-field,
.clarifying-answer-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.intent-correction-input,
.clarifying-answer-input {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 400 13px/1.5 var(--font);
  padding: 8px 10px;
}

.intent-correction-input:focus,
.clarifying-answer-input:focus {
  border-color: var(--line-strong);
  outline: 2px solid color-mix(in srgb, var(--accent) 20%, transparent);
  outline-offset: 1px;
}

.suggestion-task-card.is-review-unresolved,
.ai-question-pill.is-review-unresolved {
  border-color: var(--line-strong);
}

.review-resolution-status {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.review-resolution-status[hidden] {
  display: none;
}

.question-resolution-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.question-skip-action {
  appearance: none;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-secondary);
  font: 600 11px/1 var(--font);
  cursor: pointer;
}

.question-skip-action[aria-pressed="true"] {
  border-color: var(--text-secondary);
  background: var(--line);
  color: var(--text);
}

.suggestion-card-action {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}

.suggestion-card-action:hover:not(:disabled) {
  background: var(--line);
  color: var(--text);
}

.suggestion-card-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-card-action.is-injected,
.suggestion-card-action:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  cursor: default;
}

.suggestion-task-card.is-injected,
.suggestion-task-card:disabled,
.ai-question-pill.is-injected,
.ai-question-pill:disabled,
.ai-task-pill.is-injected,
.ai-task-pill:disabled {
  opacity: 0.78;
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
  transform: none;
}

.suggestion-task-card.is-injected.is-resolved {
  background: var(--surface-2);
  border-color: var(--line);
}

.suggestion-card-action.is-injected,
.suggestion-card-action:disabled,
.suggestion-task-card.is-injected .suggestion-card-action,
.suggestion-task-card:disabled .suggestion-card-action,
.ai-question-pill.is-injected .ai-question-pill-action,
.ai-question-pill:disabled .ai-question-pill-action,
.ai-task-pill.is-injected .ai-task-pill-action,
.ai-task-pill:disabled .ai-task-pill-action {
  color: #2e693e;
  background: var(--surface-2);
  cursor: default;
}

.critique-response p {
  margin: 0 0 14px;
}

.critique-response p:last-child {
  margin-bottom: 0;
}

.critique-response strong {
  font-weight: 600;
}

.feedback-alert {
  color: #d93025;
  font-size: 13px;
  line-height: 1.5;
}

.tensions {
  display: grid;
  gap: 8px;
}

.tension-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  transition: opacity 0.15s ease, background 0.15s ease;
}

.tension-card.resolved {
  background: var(--surface-2);
  color: var(--muted);
}

.tension-card.resolved .tension-text {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.tension-text {
  grid-column: 1 / -1;
  font-size: 13px;
  line-height: 1.45;
}

.suggestion-tag {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.copy-button {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.copy-button:hover,
.copy-button:focus-visible {
  color: var(--text);
  outline: 0;
}

.copy-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.resolve-button {
  grid-column: 2;
}

.suggestion-card-body {
  cursor: pointer;
  outline: none;
}

.suggestion-card-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.suggestion-text,
.ai-question-text,
.ai-task-text {
  font-weight: 500;
  color: #111827;
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  transition: color 0.15s ease;
}

.suggestion-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-card-action {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 3px 10px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  user-select: none;
  line-height: 1;
  white-space: nowrap;
}

.suggestion-card-action:hover:not(:disabled) {
  background: var(--line);
  color: var(--text);
}

.suggestion-card-action:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.suggestion-card-action.is-injected,
.suggestion-card-action:disabled {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  cursor: default;
}

.suggestion-task-card.is-injected,
.suggestion-task-card:disabled,
.ai-question-pill.is-injected,
.ai-question-pill:disabled,
.ai-task-pill.is-injected,
.ai-task-pill:disabled {
  opacity: 0.78;
  border-color: var(--line);
  background: var(--surface-2);
  box-shadow: none;
  transform: none;
}

.suggestion-task-card.is-injected.is-resolved {
  background: var(--surface-2);
  border-color: var(--line);
}

.suggestion-card-action.is-injected,
.suggestion-card-action:disabled,
.suggestion-task-card.is-injected .suggestion-card-action,
.suggestion-task-card:disabled .suggestion-card-action,
.ai-question-pill.is-injected .ai-question-pill-action,
.ai-question-pill:disabled .ai-question-pill-action,
.ai-task-pill.is-injected .ai-task-pill-action,
.ai-task-pill:disabled .ai-task-pill-action {
  color: #2e693e;
  background: var(--surface-2);
  cursor: default;
}

.critique-response p {
  margin: 0 0 14px;
}

.critique-response p:last-child {
  margin-bottom: 0;
}

.critique-response strong {
  font-weight: 600;
}

.feedback-alert {
  color: #d93025;
  font-size: 13px;
  line-height: 1.5;
}

.tensions {
  display: grid;
  gap: 8px;
}

.tension-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: var(--surface);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  transition: opacity 0.15s ease, background 0.15s ease;
}

.tension-card.resolved {
  background: var(--surface-2);
  color: var(--muted);
}

.tension-card.resolved .tension-text {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.tension-text {
  grid-column: 1 / -1;
  font-size: 13px;
  line-height: 1.45;
}

.suggestion-tag {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.copy-button {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.copy-button:hover,
.copy-button:focus-visible {
  color: var(--text);
  outline: 0;
}

.copy-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.resolve-button {
  grid-column: 2;
  justify-self: end;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.resolve-button:hover,
.tension-card.resolved .resolve-button {
  border-color: rgba(45, 112, 58, 0.24);
  color: #397343;
}

/* Base Mobile Elements (hidden on desktop) */
.mobile-menu-button,
.mobile-nav-bar,
.mobile-drawer,
.mobile-backdrop,
.mobile-review-button,
.feedback-pill {
  display: none;
}

/* ==========================================================================
   MOBILE ARCHITECTURE (@media max-width: 767px)
   One primary workspace at a time: Paper (default) | Notes | History
   ========================================================================== */
@media (max-width: 767px) {
  html,
  body {
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  .app {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Concise Mobile Toolbar */
  .toolbar {
    height: 52px;
    padding: 0 14px;
    flex-shrink: 0;
    z-index: 20;
  }

  .toolbar-left,
  .toolbar-right {
    gap: 8px;
  }

  .mobile-menu-button {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
  }

  .brand {
    font-size: 18px;
  }

  /* Hide secondary desktop actions from the top toolbar on mobile */
  .toolbar-right .help-button,
  .toolbar-right .export-button,
  .toolbar-right .share-button {
    display: none !important;
  }

  /* Compact New Paper button */
  .new-paper-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 12.5px;
    gap: 5px;
  }

  /* Compact Mobile View Switcher */
  .mobile-nav-bar {
    display: flex;
    align-items: stretch;
    height: 40px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
    padding: 0 4px;
    z-index: 15;
  }

  .mobile-nav-tab {
    flex: 1;
    appearance: none;
    border: none;
    background: transparent;
    padding: 0 4px;
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
  }

  .mobile-nav-tab:hover {
    color: var(--text);
  }

  .mobile-nav-tab.is-active {
    color: var(--text);
    font-weight: 600;
    border-bottom-color: var(--accent);
  }

  .mobile-nav-tab .badge {
    margin-left: 2px;
  }

  /* Workspace Layout on Mobile */
  .workspace {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
  }

  /* One primary workspace displayed at a time */
  /* DEFAULT VIEW: PAPER */
  body[data-mobile-view="paper"] .center-panel {
    display: flex;
    flex: 1 1 0%;
    width: 100%;
    min-width: 0;
    min-height: 0;
  }

  body[data-mobile-view="paper"] .left-panel,
  body[data-mobile-view="paper"] .right-panel {
    display: none !important;
  }

  /* NOTES VIEW */
  body[data-mobile-view="notes"] .left-panel {
    display: flex;
    flex: 1 1 0%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    border-right: none;
  }

  body[data-mobile-view="notes"] .center-panel,
  body[data-mobile-view="notes"] .right-panel {
    display: none !important;
  }

  /* HISTORY VIEW */
  body[data-mobile-view="history"] .right-panel {
    display: flex;
    flex: 1 1 0%;
    width: 100%;
    min-width: 0;
    min-height: 0;
    border-left: none;
  }

  body[data-mobile-view="history"] .center-panel,
  body[data-mobile-view="history"] .left-panel {
    display: none !important;
  }

  /* Fallback: if data-mobile-view is not set, default to paper */
  body:not([data-mobile-view]) .center-panel {
    display: flex;
    flex: 1 1 0%;
    width: 100%;
  }

  body:not([data-mobile-view]) .left-panel,
  body:not([data-mobile-view]) .right-panel {
    display: none !important;
  }

  /* Mobile Editor Layout */
  .editor-wrap {
    width: 100%;
    min-width: 0;
    height: 100%;
  }

  .editor-topbar {
    padding: 10px 16px;
    gap: 10px;
    width: 100%;
    max-width: 100%;
  }

  .editor-title {
    font-size: 22px;
    margin-bottom: 0;
    min-width: 0;
  }

  .editor-topbar-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .editor-topbar-actions .checkpoint-button {
    height: 30px;
    padding: 0 8px;
    font-size: 12px;
    gap: 4px;
    margin-bottom: 0;
  }

  .editor-topbar-actions .mobile-review-button {
    display: inline-flex;
    align-items: center;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
  }

  .markdown-preview {
    padding: 18px 16px 22px;
  }

  .markdown-preview-header {
    flex-direction: column;
    gap: 14px;
  }

  .markdown-preview-actions {
    width: 100%;
  }

  .markdown-preview-actions button {
    flex: 1;
  }

  .markdown-preview-content {
    padding: 20px;
  }

  .review-modal-backdrop {
    padding: 12px;
  }

  .review-modal {
    max-height: 92vh;
  }

  .editor-topbar-actions .mobile-review-button:hover {
    background: var(--surface-2);
    border-color: var(--line-strong);
  }

  .editor-topbar-actions .clear-sample-button {
    margin-bottom: 0;
    font-size: 12px;
  }

  .editor-column {
    padding: 0 16px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .editor {
    width: 100%;
    max-width: 100%;
    padding: 0 0 calc(40px + env(safe-area-inset-bottom));
    font-size: 15px;
    line-height: 1.6;
    min-width: 0;
  }

  /* Full-width cards and lists */
  .suggestions-container .panel-body,
  .history-body,
  .right-view .panel-body {
    padding: 14px 16px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Mobile Secondary Menu Drawer */
  .mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(82vw, 300px);
    background: var(--surface);
    border-right: 1px solid var(--line);
    box-shadow: 16px 0 36px rgba(0, 0, 0, 0.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(-105%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .mobile-drawer:not([hidden]) {
    display: flex;
    transform: translateX(0);
  }

  body.mobile-menu-open .mobile-drawer {
    transform: translateX(0);
  }

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

  .mobile-drawer-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
  }

  .mobile-drawer-close {
    width: 32px;
    height: 32px;
  }

  .mobile-drawer-body {
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
  }

  .mobile-drawer-item {
    appearance: none;
    border: none;
    background: transparent;
    padding: 10px 12px;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
  }

  .mobile-drawer-item:hover,
  .mobile-drawer-item:active {
    background: var(--surface-2);
  }

  .mobile-drawer-item svg {
    width: 17px;
    height: 17px;
    stroke: var(--muted);
    stroke-width: 1.8;
    fill: none;
    flex-shrink: 0;
  }

  .drawer-help-icon {
    display: inline-grid;
    place-items: center;
    width: 17px;
    height: 17px;
    font-weight: 700;
    font-size: 14px;
    color: var(--muted);
    line-height: 1;
  }

  .mobile-drawer-item .badge {
    margin-left: auto;
  }

  .mobile-drawer-divider {
    height: 1px;
    background: var(--line);
    margin: 6px 8px;
  }

  .mobile-backdrop {
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(18, 17, 15, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  body.mobile-menu-open .mobile-backdrop {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }
}

.history-panel {
  display: flex;
  flex: 0 0 380px;
  flex-direction: column;
  min-width: 280px;
  min-height: 0;
  border-left: 1px solid var(--line-strong);
  background: var(--page);
}

.history-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}

.history-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.history-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  margin-bottom: 16px;
}

.history-item.is-active-document {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0 0 16px 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  margin-bottom: 24px;
}

.history-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.history-item-preview {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow: hidden;
  max-height: 120px;
  position: relative;
}

.history-item-preview::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: linear-gradient(transparent, var(--surface-2));
}

.history-preview-block {
  margin-bottom: 8px;
}

.history-preview-block:last-child {
  margin-bottom: 0;
}

.history-preview-block.is-title {
  font-weight: 700;
  font-size: 1.15em;
  color: var(--text);
  margin-bottom: 10px;
}

.history-preview-block strong {
  font-weight: 700;
  color: var(--text);
}

.history-preview-block em {
  font-style: italic;
}

.history-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-item-meta {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.history-item-details {
  display: none;
}

.history-recall-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.history-recall-btn:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

/* Left panel bottom navigation */
.left-nav-bottom {
  flex-shrink: 0;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface);
}

.left-nav-bottom .nav-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.left-nav-bottom .nav-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  text-align: left;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background 0.15s ease, color 0.15s ease;
}

.left-nav-bottom .nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.left-nav-bottom .nav-item.is-active {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
}

/* Focused Modal Overlay: Recent Papers */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(18, 17, 15, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

.review-modal {
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: min(84vh, 820px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(18, 17, 15, 0.24);
}

.review-modal-header,
.review-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.review-modal-footer {
  gap: 16px;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.review-prepare-feedback {
  margin-right: auto;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.4;
}

.review-prepare-feedback[hidden] {
  display: none;
}

.review-modal-body {
  min-height: 0;
  overflow: auto;
}

.review-modal-body .suggestions-container {
  overflow: visible;
}

.review-modal-body .suggestions-container .panel-body {
  overflow: visible;
  padding: 20px;
}

.review-modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.review-modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.review-modal-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.notes-modal {
  background: var(--surface);
  width: 100%;
  max-width: 540px;
  max-height: 80vh;
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.97) translateY(8px);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-backdrop:not([hidden]) .notes-modal {
  transform: scale(1) translateY(0);
}

.notes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.notes-modal-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notes-modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.notes-modal-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.notes-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.notes-modal-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.notes-modal-new-btn:hover {
  background: var(--line);
}

.notes-modal-close {
  appearance: none;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.notes-modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.notes-modal-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  max-height: calc(80vh - 72px);
}

.notes-modal-body .note-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

