@font-face {
  font-family: Inter;
  src: url('assets/fonts/Inter-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}

@font-face {
  font-family: Manrope;
  src: url('assets/fonts/Manrope-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
}

:root {
  --brand: #4f46e5;
  --bg: #faf8ff;
  --header-bg: #f8fafc;
  --sidebar-bg: #f1f5f9;
  --surface: #fff;
  --surface-low: #f2f3ff;
  --surface-high: #e2e7ff;
  --text: #131b2e;
  --muted: #76777d;
  --outline: #c6c6cd;
  --shell-border: rgba(156, 166, 186, 0.12);
  --danger: #dc2626;
  --success: #10b981;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, 'Segoe UI', Roboto, Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  padding: 0 24px;
  border: 1px solid var(--shell-border);
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 4px 2px;
}

.brand span {
  font-family: Manrope, Inter, sans-serif;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2.8px;
  color: var(--text);
}

.language-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 4px;
  background: var(--surface-low);
}

.lang-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  color: var(--muted);
  padding: 0;
}

.lang-btn.active {
  color: var(--brand);
  font-weight: 700;
}

.language-pill span {
  color: var(--outline);
}

.shell-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.sidebar {
  width: 256px;
  display: flex;
  flex-direction: column;
  padding-top: 26px;
  border: 1px solid var(--shell-border);
  border-top: 0;
  background: var(--sidebar-bg);
}

.sidebar-accent {
  height: 2px;
  width: 28px;
  margin: 0 0 14px 20px;
  background: var(--brand);
}

.side-item {
  margin: 3px 10px;
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--text) 72%, transparent);
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}

.side-item.selected {
  background: var(--surface-high);
  color: var(--brand);
  font-weight: 700;
}

.side-icon {
  width: 18px;
  text-align: center;
  font-size: 15px;
}

.donation-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
}

.donation-link img,
.partner-minmol img,
.partner-tatfor img {
  opacity: 0;
  transition: opacity 220ms ease;
}

.donation-link img.ready,
.partner-minmol img.ready,
.partner-tatfor img.ready {
  opacity: 1;
}

.sidebar-spacer {
  flex: 1;
}

.partners {
  padding: 8px 18px 20px;
}

.partners h2,
.support-panel h2 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.partner-minmol,
.partner-tatfor {
  margin-top: 10px;
  min-height: 68px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.partner-tatfor {
  margin-top: 8px;
}

.partner-minmol span,
.partner-tatfor span {
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-family: Manrope, Inter, sans-serif;
  font-size: 15px;
  line-height: 1.15;
  font-weight: 700;
  color: color-mix(in srgb, var(--text) 82%, transparent);
}

.support-panel {
  padding: 2px 18px 20px;
}

.support-links {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.donation-link-large {
  width: 28px;
  height: 28px;
  border: 1px solid var(--shell-border);
  border-radius: 6px;
  background: var(--surface);
}

.main-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--shell-border);
  border-left: 0;
  border-top: 0;
}

.page {
  animation: fadein 180ms ease;
}

.workspace-page {
  display: flex;
  flex-direction: column;
}

.workspace-panel {
  height: clamp(380px, 64vh, 860px);
  border-radius: 10px;
  border: 1px solid var(--shell-border);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.pane {
  padding: 24px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.pane h3 {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.pane-original {
  background: var(--surface);
  border-right: 1px solid var(--shell-border);
}

.pane-corrected {
  background: var(--surface-low);
}

#original-input {
  width: 100%;
  height: 100%;
  min-height: 140px;
  border: 0;
  resize: none;
  background: transparent;
  color: var(--text);
  font-size: 30px;
  line-height: 1.55;
  outline: none;
}

.corrected-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.corrected-head h3 {
  color: var(--brand);
  margin: 0;
}

.streaming-state {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.streaming-state.is-hidden {
  display: none;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgb(16 185 129 / 20%);
  border-top-color: var(--success);
  animation: spin 0.8s linear infinite;
}

.corrected-output {
  flex: 1;
  min-height: 0;
  margin-top: 12px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 30px;
  line-height: 1.55;
}

.corrected-output.placeholder {
  color: var(--muted);
}

.corrected-output.error {
  color: var(--danger);
}

.action-bar {
  margin-top: 20px;
  border-radius: 10px;
  background: var(--surface-high);
  border: 1px solid var(--shell-border);
  padding: 10px 12px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  bottom: 12px;
  z-index: 8;
}

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

.btn {
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.btn-primary {
  background: #000;
  color: #fff;
}

.btn-outline {
  background: transparent;
  border-color: var(--outline);
  color: var(--text);
}

.btn:disabled,
.btn-icon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.divider {
  width: 1px;
  height: 32px;
  background: var(--outline);
}

.btn-icon {
  border: 0;
  background: transparent;
  color: color-mix(in srgb, var(--text) 72%, transparent);
  font-size: 20px;
  width: 28px;
  height: 28px;
  cursor: pointer;
}

.btn-icon.danger {
  color: var(--danger);
}

.btn-icon.active {
  color: var(--brand);
}

.metrics {
  display: flex;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-list {
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  background: var(--surface);
  padding: 16px;
}

.history-empty {
  color: var(--muted);
}

.history-day {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.history-block {
  margin-bottom: 18px;
}

.history-card {
  border: 1px solid var(--shell-border);
  border-radius: 10px;
  background: var(--surface-low);
  padding: 14px;
}

.history-card + .history-card {
  margin-top: 10px;
}

.history-time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.history-original {
  margin-top: 10px;
  color: var(--muted);
  white-space: pre-wrap;
  line-height: 1.45;
}

.history-corrected {
  margin-top: 12px;
  color: var(--brand);
  white-space: pre-wrap;
  line-height: 1.45;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-size: 14px;
  padding: 10px 14px;
  z-index: 10000;
}

.toast.error {
  background: #991b1b;
}

#boot-shell {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #f1eee7;
  z-index: 9999;
  transition: opacity 180ms ease;
  border: 1px solid rgba(156, 166, 186, 0.12);
}

#boot-shell.hide {
  opacity: 0;
}

.boot-header {
  height: 64px;
  border-bottom: 1px solid rgba(156, 166, 186, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: #f8fafc;
}

.boot-brand {
  width: 160px;
  height: 14px;
  border-radius: 4px;
  background: #dbe2ef;
}

.boot-lang {
  width: 90px;
  height: 20px;
  border-radius: 4px;
  background: #e5e9f2;
}

.boot-content {
  flex: 1;
  display: flex;
}

.boot-sidebar {
  width: 256px;
  border-right: 1px solid rgba(156, 166, 186, 0.12);
  background: #f1f5f9;
  padding: 26px 16px;
}

.boot-nav-line {
  height: 13px;
  border-radius: 4px;
  background: #dbe2ef;
  margin-bottom: 14px;
}

.boot-nav-line.short {
  width: 64%;
}

.boot-nav-line.long {
  width: 82%;
}

.boot-main {
  flex: 1;
  padding: 24px;
}

.boot-panel {
  height: min(42vh, 380px);
  min-height: 280px;
  border-radius: 10px;
  border: 1px solid rgba(156, 166, 186, 0.2);
  background: #f5f6fb;
}

.boot-actions {
  margin-top: 20px;
  height: 72px;
  border-radius: 10px;
  border: 1px solid rgba(156, 166, 186, 0.2);
  background: #eceff9;
}

.shimmer {
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 260px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { background-position: -260px 0; }
  to { background-position: calc(100% + 260px) 0; }
}

@keyframes fadein {
  from { opacity: 0.2; }
  to { opacity: 1; }
}

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

.app.focus-mode .workspace-panel {
  height: clamp(460px, 76vh, 1080px);
}

.app.focus-mode .main-area {
  padding-bottom: 10px;
}

@media (max-width: 1440px) {
  .topbar {
    padding: 0 20px;
  }

  .main-area {
    padding: 20px;
  }

  .pane {
    padding: 20px;
  }

  #original-input,
  .corrected-output {
    font-size: 28px;
  }
}

@media (max-width: 1240px) {
  .topbar {
    padding: 0 16px;
  }

  .sidebar {
    width: 232px;
  }

  .main-area {
    padding: 18px;
  }

  .pane {
    padding: 18px;
  }

  .action-bar {
    flex-wrap: wrap;
  }

  .action-left {
    flex-wrap: wrap;
  }

  .partner-minmol span,
  .partner-tatfor span {
    font-size: 14px;
  }

  #original-input,
  .corrected-output {
    font-size: 24px;
  }
}

@media (max-width: 1080px) {
  .shell-body {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    border-right: 1px solid var(--shell-border);
  }

  .workspace-panel {
    height: clamp(340px, 58vh, 720px);
    grid-template-columns: 1fr;
  }

  .pane-original {
    min-height: 220px;
    border-right: 0;
    border-bottom: 1px solid var(--shell-border);
  }

  .pane-corrected {
    min-height: 220px;
  }

  .action-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .metrics {
    margin-left: auto;
    gap: 16px;
  }

  .boot-sidebar {
    display: none;
  }

  .boot-main {
    padding: 16px;
  }

  .app.focus-mode .workspace-panel {
    height: clamp(460px, 74vh, 980px);
  }
}

@media (max-width: 768px) {
  .topbar {
    height: auto;
    min-height: 64px;
    padding: 10px 14px;
    gap: 10px;
  }

  .brand span {
    font-size: 23px;
    letter-spacing: 2px;
  }

  .language-pill {
    padding: 7px 10px;
  }

  .sidebar {
    padding-top: 14px;
  }

  .main-area {
    padding: 14px;
  }

  .pane {
    padding: 14px;
  }

  .pane-original,
  .pane-corrected {
    min-height: 170px;
  }

  #original-input,
  .corrected-output {
    font-size: 20px;
    line-height: 1.45;
  }

  .corrected-head {
    align-items: flex-start;
    gap: 8px;
  }

  .streaming-state {
    font-size: 10px;
    letter-spacing: 0.5px;
  }

  .action-bar {
    flex-direction: column;
    align-items: flex-start;
    bottom: 8px;
  }

  .metrics {
    margin-left: 0;
    gap: 12px;
    flex-wrap: wrap;
  }

  .partner-minmol span,
  .partner-tatfor span {
    font-size: 13px;
  }

  .workspace-panel,
  .app.focus-mode .workspace-panel {
    height: clamp(340px, 62vh, 620px);
  }
}

@media (max-width: 480px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand span {
    font-size: 19px;
    letter-spacing: 1.4px;
  }

  .language-pill {
    align-self: flex-end;
  }

  .side-item {
    margin: 2px 8px;
    padding: 10px;
    gap: 8px;
  }

  .workspace-panel {
    border-radius: 8px;
  }

  .btn {
    padding: 10px 12px;
    font-size: 14px;
  }

  .divider {
    display: none;
  }

  .btn-icon {
    font-size: 18px;
  }
}
