:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: #f8fafc;
  color: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f8fafc;
}

.app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.app__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: #64748b;
  margin: 0 0 8px;
}

h1 {
  margin: 0 0 12px;
  font-size: 2.4rem;
}

.subhead {
  margin: 0;
  color: #475569;
  max-width: 520px;
}

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 0.85rem;
  color: #334155;
}

.status__dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #94a3b8;
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.35);
}

.status__divider {
  opacity: 0.6;
}

.app__main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 100%;
}

.files-dropdown {
  position: relative;
}

.files-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  padding: 8px;
  min-width: 240px;
  max-height: 320px;
  overflow-y: auto;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-list__item {
  margin: 0;
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.file-list__button {
  flex: 1;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 5px 10px;
  background: #f8fafc;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.2s ease, border 0.2s ease;
}

.file-list__delete {
  border: 1px solid rgba(248, 113, 113, 0.5);
  border-radius: 6px;
  padding: 0 6px;
  background: transparent;
  color: #b91c1c;
  font-size: 0.7rem;
  line-height: 1.2;
  min-width: 1.5em;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
}

.file-list__delete:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.7);
  color: #991b1b;
}

.file-list__delete:focus-visible {
  outline: 2px solid #fecaca;
  outline-offset: 2px;
}

.file-list__button:hover {
  background: #f1f5f9;
}

.file-list__button.is-active {
  background: #e2e8f0;
  border-color: #cbd5f5;
}

.file-list__title {
  font-weight: 600;
}

.file-list__meta {
  font-size: 0.7rem;
  color: #64748b;
}

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

.panel__header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.panel__header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.panel__header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.app-version {
  font-size: 0.7rem;
  color: #94a3b8;
  font-weight: 400;
}

.app-version-button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
}

.app-version-button:hover {
  color: #64748b;
  background: #f1f5f9;
}

.app-version-button:active {
  color: #475569;
}

.app-version-button:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.app-version-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-version-button.is-updating {
  color: #2563eb;
  animation: spin 1s linear infinite;
}

.app-version-button.has-update {
  color: #22c55e;
}

#settings-button {
  position: relative;
}

.settings-button__warning {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 10px;
  height: 10px;
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: #dc2626;
  border-radius: 999px;
  pointer-events: none;
}

.settings-button__warning[hidden] {
  display: none;
}

.field--api-key.is-missing input {
  border-color: #dc2626;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.3);
}

.field--api-key.is-missing input::placeholder {
  color: #b91c1c;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.panel__description {
  margin: 0;
  color: #64748b;
  font-size: 0.95rem;
}

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

.toolbar__ai {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-left: auto;
}

.button {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.button:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.button--ghost {
  background: #e2e8f0;
  color: #1f2937;
}

.button--primary {
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #f8fafc;
  font-weight: 600;
}

.button--danger {
  background: transparent;
  color: #dc2626;
  border: 1px solid #fca5a5;
}

.button--danger:hover {
  background: #fee2e2;
  border-color: #dc2626;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.15);
}

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

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.preview-pane {
  margin: 0;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #1f2937;
  font-size: 0.875rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 112px;
  font-family: inherit;
}

.paragraphs {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.paragraph-cell {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.paragraph-cell__row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.paragraph-cell__row .paragraph-cell__input {
  flex: 1;
  min-width: 0;
}

.paragraph-cell__actions {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  gap: 4px;
}

.paragraph-cell__undo {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #fbbf24;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.paragraph-cell__undo:hover {
  background: #fde68a;
  border-color: #f59e0b;
  box-shadow: 0 3px 8px rgba(245, 158, 11, 0.2);
}

.paragraph-cell__undo:focus-visible {
  outline: 2px solid #f59e0b;
  outline-offset: 2px;
}

.paragraph-cell__copy {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #cbd5f5;
  background: #e2e8f0;
  color: #1f2937;
  font-size: 0.75rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.paragraph-cell__copy:hover {
  background: #dbe3f3;
  border-color: #b4c3f5;
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
}

.paragraph-cell__copy.is-copied {
  background: #bbf7d0;
  border-color: #22c55e;
  color: #166534;
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
}

.paragraph-cell__copy:focus-visible {
  outline: 2px solid #94a3b8;
  outline-offset: 2px;
}

.paragraph-cell__delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(248, 113, 113, 0.5);
  border-radius: 8px;
  background: transparent;
  color: #b91c1c;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border 0.2s ease, color 0.2s ease;
}

.paragraph-cell__delete:hover {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.7);
  color: #991b1b;
}

.paragraph-cell__delete:focus-visible {
  outline: 2px solid #fecaca;
  outline-offset: 2px;
}

.paragraph-cell__previous {
  margin: 0;
  font-size: 0.9rem;
  color: #94a3b8;
}

.paragraph-cell__suggestion {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #2563eb;
}

.paragraph-cell__input {
  width: 100%;
  border-radius: 12px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1f2937;
  font-size: 0.875rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 224px;
}

.paragraphs-preview {
  margin: 0;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #1f2937;
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 320px;
  font-family: inherit;
}

.panel__footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: #64748b;
  font-size: 0.85rem;
}

.panel__meta {
  margin: 0;
  color: #64748b;
  font-size: 0.85rem;
}

.panel__status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint {
  margin: 0;
}

.hint--error {
  color: #b91c1c;
}

.field {
  display: grid;
  gap: 6px;
  font-size: 0.9rem;
}

.field--inline {
  grid-auto-flow: column;
  align-items: center;
  gap: 6px;
}

.field input,
.field select,
.field textarea {
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  padding: 10px 12px;
  background: #f8fafc;
  color: #1f2937;
  font-family: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.field__hint {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: -4px;
}

.dialog {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  width: min(800px, calc(100% - 32px));
  max-width: 800px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.15);
}

.dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.dialog__title {
  margin: 0 0 20px;
  font-size: 1.2rem;
}

.dialog__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dialog__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.error {
  margin: 0;
  color: #b91c1c;
  font-size: 0.9rem;
}

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

@media (max-width: 768px) {
  .app {
    max-width: 100%;
    padding: 24px 16px 48px;
  }

  h1 {
    font-size: 2rem;
  }

  .dialog {
    width: calc(100% - 32px);
    max-width: 100%;
  }
}

@media (max-width: 1024px) {
  .app__main {
    grid-template-columns: minmax(0, 1fr);
  }
}
