:root {
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-soft: #fff7ef;
  --ink: #0e1314;
  --muted: #647079;
  --line: #e5e8eb;
  --orange: #f58220;
  --orange-dark: #c95f08;
  --blue: #123c49;
  --teal: #0f766e;
  --green: #15803d;
  --red: #b42318;
  --shadow: 0 18px 44px rgba(14, 19, 20, 0.08);
  --radius: 8px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #101416;
  --panel: #171d20;
  --panel-soft: #251b12;
  --ink: #edf2f4;
  --muted: #a7b0b6;
  --line: #283137;
  --orange: #ff982f;
  --orange-dark: #ffb364;
  --blue: #83c5d4;
  --teal: #5eead4;
  --green: #86efac;
  --red: #fca5a5;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 420px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-logo {
  width: 210px;
  margin: 0 auto 22px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius);
}

.tab-button,
.segmented button {
  min-height: 40px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.tab-button.active,
.segmented button.active {
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 1px 4px rgba(14, 19, 20, 0.1);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.input,
textarea,
select {
  width: 100%;
  min-height: 44px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  padding: 11px 12px;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

.input:focus,
textarea:focus,
select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 130, 32, 0.15);
}

.primary,
.secondary,
.ghost,
.icon-button,
.chip,
.module-card,
.result-card,
.nav-item,
.bottom-item,
.banner-dot {
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.primary {
  min-height: 44px;
  width: 100%;
  border-radius: var(--radius);
  color: #ffffff;
  background: var(--orange);
  font-weight: 800;
}

.secondary {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 14px;
  color: var(--orange-dark);
  background: var(--panel-soft);
  font-weight: 800;
}

.ghost {
  min-height: 38px;
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.primary:hover,
.secondary:hover,
.ghost:hover,
.icon-button:hover,
.chip:hover,
.module-card:hover,
.result-card:hover {
  transform: translateY(-1px);
}

.message {
  min-height: 20px;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 278px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.side-logo {
  width: 192px;
  margin: 0 auto 24px;
}

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

.nav-item,
.bottom-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  border-radius: var(--radius);
  color: var(--muted);
  background: transparent;
  padding: 0 12px;
  font-weight: 800;
  text-align: left;
}

.nav-item.active,
.bottom-item.active {
  color: var(--orange-dark);
  background: var(--panel-soft);
}

.nav-item img,
.bottom-item img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.workspace {
  min-width: 0;
  padding: 22px clamp(16px, 4vw, 48px) 34px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.search-box {
  position: relative;
}

.search-box img {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  opacity: 0.7;
}

.search-box input {
  padding-left: 42px;
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
  white-space: nowrap;
}

.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #ffffff;
  background: var(--blue);
  font-size: 13px;
}

.view {
  display: grid;
  gap: 16px;
}

.surface {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 320px);
  gap: 18px;
  align-items: center;
  overflow: hidden;
  padding: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--orange-dark);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(27px, 4vw, 42px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 10px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.banner-image {
  aspect-ratio: 16 / 9;
  width: 100%;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--bg);
}

.brand-panel {
  display: grid;
  place-items: center;
  min-height: 190px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-soft), var(--panel));
  border: 1px solid var(--line);
}

.brand-panel img {
  width: min(82%, 280px);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  padding: 14px;
}

.stat strong {
  display: block;
  font-size: 22px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 34px;
  padding: 0 11px;
  color: var(--blue);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.chip.active {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(164px, 1fr));
  gap: 12px;
}

.module-card {
  min-height: 134px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.module-card img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  margin-bottom: 14px;
}

.module-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--ink);
}

.module-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.results {
  display: grid;
  gap: 10px;
}

.result-card {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 76px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
}

.result-card img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.result-card strong,
.result-card span {
  display: block;
}

.result-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 4px 7px;
  color: var(--teal);
  background: rgba(15, 118, 110, 0.1);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.detail {
  display: grid;
  gap: 14px;
}

.detail-header {
  padding: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.icon-row {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--line);
}

.icon-button img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.detail-section {
  padding: 18px;
}

.content-text {
  color: var(--muted);
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.content-text h3 {
  margin: 14px 0 8px;
  color: var(--ink);
  font-size: 16px;
}

.content-text p {
  margin: 0 0 10px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.calculator-shell,
.notes-shell,
.settings-shell,
.chat-shell,
.shift-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 14px;
}

.segmented {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.calc-panel,
.note-panel,
.settings-panel,
.chat-panel,
.shift-panel,
.flashcard-panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-box {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel-soft);
  border: 1px solid rgba(245, 130, 32, 0.24);
}

.result-box strong {
  display: block;
  margin-bottom: 4px;
}

.flashcard {
  min-height: 250px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  text-align: center;
}

.flashcard strong {
  display: block;
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.2;
}

.flashcard-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.note-list,
.chat-list,
.shift-list {
  display: grid;
  gap: 10px;
}

.note-item,
.chat-message,
.shift-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.note-item header,
.shift-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.note-item small,
.shift-item small {
  color: var(--muted);
  font-weight: 700;
}

.chat-message.user {
  margin-left: 44px;
  border-color: rgba(245, 130, 32, 0.3);
  background: var(--panel-soft);
}

.chat-message.bot {
  margin-right: 44px;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  display: none;
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    padding-bottom: 78px;
  }

  .side-nav {
    display: none;
  }

  .workspace {
    padding: 14px 14px 24px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .topbar .secondary {
    display: none;
  }

  .profile-pill span:not(.avatar) {
    display: none;
  }

  .hero-card,
  .calculator-shell,
  .notes-shell,
  .settings-shell,
  .chat-shell,
  .shift-shell {
    grid-template-columns: 1fr;
  }

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

  .two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 8px;
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(14px);
  }

  .bottom-item {
    justify-content: center;
    min-height: 56px;
    padding: 0;
  }

  .bottom-item span {
    display: none;
  }
}

@media (max-width: 520px) {
  .auth-card {
    padding: 18px;
  }

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

  .module-card {
    min-height: 128px;
  }

  .result-card {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .result-card .tag-list {
    grid-column: 2;
  }

  h1 {
    font-size: 29px;
  }
}
