:root {
  color-scheme: dark;
  --bg: #0d1310;
  --panel: #141b17;
  --panel-2: #1a231e;
  --paper: #101713;
  --line: rgba(237, 247, 239, 0.1);
  --text: #f4f8f1;
  --muted: rgba(244, 248, 241, 0.62);
  --accent: #54d978;
  --accent-ink: #07110b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7f0;
  --panel: #ffffff;
  --panel-2: #edf3ea;
  --paper: #fbfdf8;
  --line: rgba(22, 41, 28, 0.12);
  --text: #132017;
  --muted: rgba(19, 32, 23, 0.6);
  --accent: #2f9f52;
  --accent-ink: #fafff7;
  --shadow: 0 24px 70px rgba(22, 41, 28, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 296px;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  transition: width 180ms ease, padding 180ms ease;
}

body.sidebar-collapsed .sidebar {
  width: 72px;
  padding: 18px 10px;
}

.sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -1px;
  display: grid;
  width: 32px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
}

.brand,
.profile-button,
.nav-item,
.search-button {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
}

.brand {
  border: 0;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 900;
}

.brand span,
.profile-button span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
}

.search-button,
.nav-item,
.profile-button {
  padding: 0 12px;
  font-weight: 800;
}

.nav-item:hover,
.profile-button:hover,
.search-button:hover {
  border-color: color-mix(in srgb, var(--accent), transparent 35%);
}

.nav-item.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-group p {
  margin: 8px 0 0;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-button {
  margin-top: auto;
}

body.sidebar-collapsed .brand strong,
body.sidebar-collapsed .search-button,
body.sidebar-collapsed .nav-group,
body.sidebar-collapsed .profile-button strong {
  display: none;
}

.app-shell {
  position: fixed;
  inset: 0 0 0 296px;
  overflow: hidden;
  background: var(--bg);
  transition: left 180ms ease;
}

body.sidebar-collapsed .app-shell {
  left: 72px;
}

.workspace-view {
  display: none;
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: clamp(28px, 5vw, 64px);
}

.workspace-view.active {
  display: block;
}

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

.topbar p,
.work-panel p,
.drawer-header p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.6rem, 7vw, 6rem);
  line-height: 0.94;
  letter-spacing: 0;
}

.icon-button,
.primary-button,
.drawer-action,
.hero-card button,
.paper-header button {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 900;
}

.hero-card,
.action-card,
.recent article,
.work-panel,
.paper,
.answer-page,
.answer-box,
.drawer,
.billing-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  max-width: 980px;
  margin: 46px 0 28px;
  padding: 22px;
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--accent), transparent 82%), transparent 58%),
    var(--panel);
}

.hero-card span,
.action-card span,
.recent span,
.answer-box span,
.billing-card span {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-card strong,
.action-card strong,
.recent strong {
  display: block;
  margin-top: 6px;
  font-size: 1.2rem;
}

small,
.hero-card small,
.action-card small,
.recent small,
.answer-box p,
.billing-card p {
  color: var(--muted);
  line-height: 1.5;
}

.action-grid,
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 1120px;
}

.action-card,
.recent article {
  min-height: 170px;
  padding: 20px;
  color: var(--text);
  text-align: left;
  background:
    linear-gradient(0deg, color-mix(in srgb, var(--accent), transparent 88%), transparent 62%),
    var(--panel);
}

.section-title {
  display: flex;
  max-width: 1120px;
  align-items: center;
  justify-content: space-between;
  margin: 42px 0 16px;
}

.section-title h2 {
  margin: 0;
}

.section-title button {
  background: transparent;
  color: var(--accent);
  font-weight: 900;
}

.desk-layout,
.split-view {
  display: grid;
  min-height: calc(100vh - clamp(56px, 10vw, 128px));
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
}

.split-view {
  grid-template-columns: 420px minmax(0, 1fr);
}

.paper,
.answer-page {
  min-height: 620px;
  padding: 22px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
}

.paper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.paper-header span {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.paper textarea,
.work-panel textarea {
  width: 100%;
  min-height: 420px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: color-mix(in srgb, var(--panel), transparent 18%);
  color: var(--text);
  outline: none;
}

.work-panel {
  padding: 22px;
}

.work-panel h1 {
  margin-bottom: 22px;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
}

output {
  display: grid;
  min-height: 78px;
  place-items: center end;
  margin-bottom: 14px;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--panel-2);
  font-size: 2rem;
  font-weight: 900;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.calc-grid button {
  min-height: 54px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
}

.calc-grid button.operator,
.calc-grid button.equals {
  background: var(--accent);
  color: var(--accent-ink);
}

.upload-control {
  display: grid;
  min-height: 48px;
  place-items: center;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  font-weight: 900;
}

.upload-control input {
  display: none;
}

.answer-page {
  display: grid;
  align-content: start;
  gap: 14px;
}

.answer-box {
  padding: 18px;
  background: color-mix(in srgb, var(--panel), transparent 10%);
  box-shadow: none;
}

.answer-box.muted,
.paper-empty {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.answer-box h2 {
  margin: 10px 0 0;
  font-size: 2rem;
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(0, 0, 0, 0.28);
}

.drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: block;
  width: min(440px, 92vw);
  padding: 24px;
  border-radius: 0;
  transform: translateX(-105%);
  transition: transform 180ms ease;
}

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

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

.drawer-header h2 {
  margin: 0;
  font-size: 2rem;
}

.close-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 1.4rem;
}

.drawer-tabs,
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}

.segmented {
  grid-template-columns: repeat(2, 1fr);
}

.drawer-tab,
.segmented button {
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 900;
}

.drawer-tab.active,
.segmented button.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.drawer-panel {
  display: none;
}

.drawer-panel.active {
  display: grid;
  gap: 14px;
}

.theme-list {
  display: grid;
  gap: 10px;
}

.theme-choice,
.setting-row,
.drawer-action,
.billing-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 900;
  text-align: left;
}

.theme-choice {
  justify-content: flex-start;
}

.theme-choice.active {
  border-color: var(--accent);
}

.theme-choice span {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--swatch);
}

.setting-row small {
  display: block;
}

.billing-card {
  display: grid;
  justify-items: start;
}

.billing-card strong {
  font-size: 1.7rem;
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .sidebar {
    width: 220px;
    padding: 18px 14px;
  }

  body.sidebar-collapsed .sidebar {
    width: 72px;
    padding: 18px 10px;
  }

  .app-shell {
    position: fixed;
    inset: 0 0 0 220px;
    margin-left: 0;
  }

  body.sidebar-collapsed .app-shell {
    left: 72px;
  }

  .workspace-view {
    padding: 24px;
  }

  .action-grid,
  .recent-grid,
  .desk-layout,
  .split-view {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(2.3rem, 9vw, 4rem);
  }
}

@media (max-width: 640px) {
  .sidebar {
    width: 76px;
    padding: 14px 10px;
  }

  .brand strong,
  .search-button,
  .nav-group,
  .profile-button strong {
    display: none;
  }

  .app-shell {
    left: 76px;
  }
}
