:root {
  color-scheme: dark;
  --bg: #0b0f17;
  --panel: #121824;
  --panel-2: #171f2d;
  --panel-3: #202b3c;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f3f6f9;
  --muted: #97a3b5;
  --subtle: #6d788b;
  --accent: #d7ff52;
  --accent-ink: #172000;
  --blue: #82abff;
  --danger: #ff8f8f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 80% -12%, rgba(130, 171, 255, 0.13), transparent 34%),
    var(--bg);
}

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

button {
  color: inherit;
}

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

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  padding-top: var(--safe-top);
}

.topbar {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 23, 0.86);
  backdrop-filter: blur(20px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 11px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 19px;
  font-weight: 850;
}

.brand-copy strong,
.brand-copy small {
  display: block;
}

.brand-copy strong {
  font-size: 14px;
}

.brand-copy small {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 9px;
}

.header-actions {
  display: flex;
  gap: 7px;
}

.icon-button {
  display: flex;
  min-width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  background: var(--panel);
}

.icon-button span {
  font-size: 10px;
  font-weight: 700;
}

.main {
  min-height: 0;
}

.practice-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  min-height: 0;
  padding: 16px 15px 8px;
}

.session-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 0 3px 12px;
}

.eyebrow {
  color: var(--subtle);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.15em;
}

.scenario-label {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 5px;
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
  font-weight: 680;
}

.level-pill {
  padding: 6px 9px;
  border: 1px solid rgba(215, 255, 82, 0.22);
  border-radius: 99px;
  color: var(--accent);
  background: rgba(215, 255, 82, 0.05);
  font-size: 8px;
  font-weight: 750;
}

.welcome {
  display: flex;
  max-width: 390px;
  margin: auto;
  align-items: center;
  flex-direction: column;
  padding: 20px;
  text-align: center;
}

.welcome[hidden] {
  display: none;
}

.voice-orb {
  display: grid;
  width: 104px;
  height: 104px;
  place-items: center;
  border: 1px solid #3d4d27;
  border-radius: 50%;
  color: var(--accent);
  background:
    radial-gradient(circle, rgba(215, 255, 82, 0.17), transparent 68%),
    var(--panel);
  box-shadow: 0 0 60px rgba(215, 255, 82, 0.08);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.15em;
}

.welcome h1 {
  margin: 21px 0 0;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.welcome p {
  margin: 13px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.welcome small {
  margin-top: 12px;
  color: var(--subtle);
  font-size: 9px;
}

.messages {
  display: none;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 2px 2px 16px;
  -webkit-overflow-scrolling: touch;
}

.messages.active {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.message {
  display: flex;
  max-width: 92%;
  gap: 8px;
  animation: enter 180ms ease both;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 29px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--accent);
  background: var(--panel);
  font-size: 8px;
  font-weight: 800;
}

.message.user .avatar {
  color: var(--blue);
}

.message-content {
  min-width: 0;
}

.bubble {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 4px 15px 15px;
  background: var(--panel);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user .bubble {
  border-radius: 15px 4px 15px 15px;
  background: var(--panel-2);
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  color: var(--subtle);
  font-size: 8px;
}

.message.user .message-meta {
  justify-content: flex-end;
}

.message-meta button {
  padding: 0;
  border: 0;
  color: var(--blue);
  background: transparent;
  font-size: 8px;
}

.feedback-card {
  margin-top: 7px;
  padding: 11px;
  border: 1px solid #2c405f;
  border-radius: 11px;
  background: #111a29;
}

.feedback-head {
  color: var(--blue);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.feedback-item {
  margin-top: 9px;
}

.feedback-type {
  color: var(--accent);
  font-size: 8px;
  font-weight: 750;
  text-transform: uppercase;
}

.feedback-change {
  margin-top: 4px;
  color: var(--text);
  font-size: 10px;
  line-height: 1.45;
}

.feedback-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.feedback-pronunciation {
  color: var(--blue);
}

.quick-tools {
  display: none;
  justify-content: space-between;
  padding: 4px 2px 7px;
}

.quick-tools.active {
  display: flex;
}

.quick-tools button {
  padding: 7px 9px;
  border: 0;
  color: var(--subtle);
  background: transparent;
  font-size: 9px;
}

.composer {
  position: relative;
  z-index: 5;
  padding: 9px 15px calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--line);
  background: rgba(11, 15, 23, 0.94);
  backdrop-filter: blur(20px);
}

.text-row {
  display: flex;
  gap: 7px;
}

.text-row input {
  min-width: 0;
  flex: 1;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  color: var(--text);
  background: var(--panel);
  font-size: 16px;
}

.send-button {
  width: 45px;
  border: 0;
  border-radius: 12px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 19px;
  font-weight: 800;
}

.voice-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.mic-button {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--panel-2);
  text-align: left;
}

.mic-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent);
  background: rgba(215, 255, 82, 0.07);
  font-size: 10px;
}

.mic-button.recording {
  border-color: rgba(255, 143, 143, 0.4);
  background: rgba(255, 143, 143, 0.08);
}

.mic-button.recording .mic-icon {
  color: var(--danger);
  animation: blink 0.9s infinite;
}

.mic-copy {
  min-width: 0;
}

.mic-copy strong,
.mic-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mic-copy strong {
  font-size: 11px;
  font-weight: 680;
}

.mic-copy small {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 8px;
}

.replay-button {
  width: 68px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-size: 9px;
}

.primary,
.secondary {
  min-height: 42px;
  padding: 10px 15px;
  border-radius: 11px;
  font-weight: 720;
}

.primary {
  border: 0;
  color: var(--accent-ink);
  background: var(--accent);
}

.secondary {
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.large {
  min-width: 154px;
  padding: 13px 22px;
}

.full {
  width: 100%;
  margin-top: 10px;
}

.sheet-backdrop {
  position: fixed;
  z-index: 20;
  display: none;
  inset: 0;
  align-items: flex-end;
  background: rgba(3, 6, 11, 0.74);
  backdrop-filter: blur(8px);
}

.sheet-backdrop.open {
  display: flex;
}

.sheet {
  width: 100%;
  max-height: 82dvh;
  overflow-y: auto;
  padding: 21px 18px calc(24px + var(--safe-bottom));
  border: 1px solid var(--line-strong);
  border-radius: 22px 22px 0 0;
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}

.sheet.tall {
  max-height: 91dvh;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.sheet h2 {
  margin: 6px 0 0;
  font-size: 22px;
  letter-spacing: -0.035em;
}

.close-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 20px;
}

.sheet-intro {
  margin: 12px 0 17px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.sheet label {
  display: grid;
  gap: 6px;
  margin-bottom: 13px;
}

.sheet label span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.sheet input,
.sheet select,
.sheet textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
}

.sheet textarea {
  min-height: 105px;
  resize: vertical;
  line-height: 1.5;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 17px;
}

.scenario-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.scenario-grid button {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--panel-2);
  text-align: left;
}

.scenario-grid span,
.scenario-grid strong,
.scenario-grid small {
  display: block;
}

.scenario-grid span {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 18px;
}

.scenario-grid strong {
  font-size: 11px;
}

.scenario-grid small {
  margin-top: 5px;
  color: var(--subtle);
  font-size: 8px;
}

.translation-result {
  margin-top: 13px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel-2);
}

.translation-result[hidden] {
  display: none;
}

.translation-result > p {
  margin: 9px 0 0;
  font-size: 14px;
  line-height: 1.55;
}

.translation-result .explanation {
  color: var(--muted);
  font-size: 10px;
}

.alternatives {
  margin-top: 8px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.5;
}

.review-summary,
.review-block {
  margin-top: 13px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.review-summary {
  border-left: 3px solid var(--accent);
  font-size: 12px;
  line-height: 1.55;
}

.review-block h3 {
  margin: 0 0 8px;
  font-size: 12px;
}

.review-block p,
.review-block li {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.review-block ul {
  margin: 0;
  padding-left: 18px;
}

.history-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

.history-item + .history-item {
  margin-top: 8px;
}

.history-item strong {
  font-size: 12px;
}

.history-item p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.history-item small {
  color: var(--subtle);
  font-size: 8px;
}

.history-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}

.history-actions button {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 8px;
}

.status-toast {
  position: fixed;
  z-index: 40;
  right: 14px;
  bottom: calc(104px + var(--safe-bottom));
  left: 14px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  color: var(--text);
  background: var(--panel-3);
  font-size: 11px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 180ms ease;
}

.status-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.status-toast.error {
  border-color: rgba(255, 143, 143, 0.4);
}

.busy-overlay {
  position: fixed;
  z-index: 35;
  display: none;
  inset: 0;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 11, 0.36);
  backdrop-filter: blur(3px);
}

.busy-overlay.open {
  display: flex;
}

.busy-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 17px;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  background: var(--panel-3);
  font-size: 11px;
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
}

@media (min-width: 700px) {
  body {
    display: grid;
    place-items: center;
    background: #070a10;
  }

  .app-shell {
    width: 430px;
    height: 900px;
    max-height: 100vh;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.45);
  }

  .sheet-backdrop {
    position: absolute;
    width: 430px;
    height: 900px;
    max-height: 100vh;
    margin: auto;
    inset: 0;
    border-radius: 28px;
    overflow: hidden;
  }
}
