:root {
  color-scheme: light;
  font-family: "Manrope", "Segoe UI", "Trebuchet MS", sans-serif;
  color: #0f172a;
  background: #f6f7fa;
  font-synthesis: none;
  line-height: 1.55;
  --ink: #0f172a;
  --muted: #4a5568;
  --forest: #1e3a8a;
  --forest-soft: #e4ecff;
  --sand: #eef4f3;
  --paper: #ffffff;
  --border: #dce2ef;
  --accent: #f6a623;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  color: #e8eefc;
  background: #08101f;
  --ink: #e8eefc;
  --muted: #afbddc;
  --forest: #8db1ff;
  --forest-soft: #253862;
  --sand: #1c2740;
  --paper: #101b32;
  --border: #2a3b67;
  --accent: #f2b84f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: clip;
  background:
    radial-gradient(circle at 12% 8%, rgba(42, 161, 152, 0.2), transparent 30rem),
    radial-gradient(circle at 88% 16%, rgba(30, 58, 138, 0.2), transparent 26rem),
    var(--paper);
}

button,
textarea {
  font: inherit;
}

.learn-shell {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(18rem, 1fr) auto auto;
  width: min(780px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 2.75rem 0 2rem;
}

.learn-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  margin-top: 0.8rem;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 0.65rem;
}

.theme-button {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
}

.feedback-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  color: #fff;
  background: linear-gradient(135deg, var(--forest), #2aa198);
  box-shadow: 0 16px 35px rgba(17, 24, 39, 0.09);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.language-switcher {
  display: flex;
  gap: 0.35rem;
}

.locale-button {
  padding: 0.35rem 0.55rem;
  border-color: var(--border);
  color: var(--forest);
  background: transparent;
  font-size: 0.78rem;
}

.locale-button[aria-pressed="true"] {
  border-color: var(--forest);
  background: var(--forest-soft);
}

.eyebrow,
.identity,
.slogan,
.composer-footer p {
  margin: 0;
}

.eyebrow {
  color: var(--forest);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1 {
  margin: 0.2rem 0 0.3rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 7vw, 4.2rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}

.identity {
  max-width: 39rem;
  color: var(--muted);
  font-size: 1rem;
}

.slogan {
  margin-top: 1.3rem;
  color: var(--forest);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  font-style: italic;
}

.limitation {
  margin: 1.25rem 0 1rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid #897550;
  color: #584d38;
  background: #ebe6dc;
  font-size: 0.9rem;
}

.transcript {
  min-height: 18rem;
  max-height: 55vh;
  overflow-y: auto;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--paper);
  box-shadow: 0 16px 35px rgba(17, 24, 39, 0.09);
}

.empty-state {
  display: grid;
  min-height: 15rem;
  place-content: center;
  text-align: center;
}

.empty-state p {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.empty-state span {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.message {
  max-width: 88%;
  margin-bottom: 1rem;
}

.message:last-child {
  margin-bottom: 0;
}

.message.learner {
  margin-left: auto;
}

.message-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.message-text {
  margin: 0;
  padding: 0.8rem 0.9rem;
  border-radius: 0.75rem;
  background: color-mix(in srgb, var(--forest-soft) 90%, var(--paper));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.learner .message-text {
  background: var(--sand);
}

.takeaway-card {
  margin-top: 0.8rem;
  padding: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: color-mix(in srgb, var(--paper) 94%, transparent);
}

.takeaway-title {
  margin: 0;
  color: var(--forest);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#takeaway-text {
  margin: 0.4rem 0 0.8rem;
  color: var(--muted);
}

.composer {
  margin-top: 1rem;
}

.composer label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  resize: vertical;
  border: 1px solid #aaa99f;
  border-radius: 0.7rem;
  padding: 0.8rem;
  color: var(--ink);
  background: var(--paper);
}

textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(49, 87, 67, 0.24);
  outline-offset: 2px;
}

.composer-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.65rem;
}

.composer-footer p {
  color: var(--muted);
  font-size: 0.8rem;
}

button {
  border: 1px solid var(--forest);
  border-radius: 0.55rem;
  padding: 0.55rem 1rem;
  color: #fff;
  background: linear-gradient(135deg, var(--forest), #2aa198);
  cursor: pointer;
}

.clear-button {
  flex: 0 0 auto;
  color: var(--forest);
  background: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

@media (max-width: 600px) {
  .learn-shell {
    width: min(100% - 20px, 780px);
    padding: 1.35rem 0 6rem;
  }

  .learn-header {
    display: block;
  }

  .header-actions {
    justify-items: stretch;
    margin-top: 1rem;
  }

  .language-switcher {
    justify-content: flex-start;
  }

  .locale-button {
    width: auto;
  }

  .clear-button {
    margin-top: 0;
  }

  .transcript {
    min-height: 16rem;
    max-height: 50vh;
    padding: 0.85rem;
  }

  .message {
    max-width: 96%;
  }

  .composer-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-footer button {
    width: 100%;
    flex: 0 0 auto;
  }

  .feedback-fab {
    right: 0.75rem;
    top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
    bottom: auto;
    max-width: calc(100vw - 1.5rem);
    padding: 0.48rem 0.75rem;
    font-size: 0.75rem;
  }
}
