:root {
  color-scheme: light;
  --page: #f6f7fb;
  --surface: #ffffff;
  --ink: #1d2240;
  --muted: #565d76;
  --line: #e0e3ef;
  --accent: #5138b5;
  --accent-hover: #42299f;
  --accent-soft: #efebff;
  --error: #982334;
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 260px;
  margin: 0;
  background: var(--page);
  color: var(--ink);
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid #735bd9;
  outline-offset: 3px;
}

.site-header { border-bottom: 1px solid var(--line); }

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  max-width: 1240px;
  min-height: 72px;
  padding: 12px clamp(16px, 5vw, 52px);
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 720;
  letter-spacing: -.025em;
  text-decoration: none;
}

.brand-icon, .file-icon, .activity-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.brand-icon {
  width: 35px;
  height: 35px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
}

.brand-icon i, .file-icon i, .activity-icon i {
  width: 2px;
  height: 8px;
  border-radius: 4px;
  background: currentColor;
}

:is(.brand-icon, .file-icon, .activity-icon) i:nth-child(2n) { height: 13px; }
:is(.brand-icon, .file-icon, .activity-icon) i:nth-child(3) { height: 18px; }

.model-badge {
  padding: 6px 11px;
  border: 1px solid #e3dcfb;
  border-radius: 99px;
  background: #f2eeff;
  color: #4a339f;
  font-size: .79rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.header-actions, .account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  min-width: 0;
}

.account-email {
  max-width: min(28vw, 260px);
  overflow: hidden;
  color: var(--muted);
  font-size: .86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-bar .button {
  flex: none;
  min-height: 36px;
  padding: 6px 11px;
}

.workspace {
  max-width: 760px;
  padding: clamp(44px, 9vh, 105px) 20px 56px;
  margin: 0 auto;
}

.intro {
  margin-bottom: clamp(22px, 5vw, 36px);
  text-align: center;
}

.intro h1 {
  margin: 0;
  font-size: clamp(2.15rem, 5vw, 3.65rem);
  font-weight: 760;
  letter-spacing: -.065em;
  line-height: 1.08;
}

.intro p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: clamp(.98rem, 2.4vw, 1.13rem);
  line-height: 1.55;
}

.panel {
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: 23px;
  background: var(--surface);
  box-shadow: 0 15px 42px #232b5d0c, 0 2px 6px #232b5d08;
}

.auth-loading { color: var(--muted); text-align: center; }
.auth-panel { max-width: 430px; margin: 0 auto; }
.auth-form { display: flex; flex-direction: column; margin-top: 21px; }
.auth-form label { margin-bottom: 6px; font-size: .9rem; font-weight: 650; }
.auth-form input + label { margin-top: 14px; }
.auth-form input {
  width: 100%;
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid #cbd0e1;
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.auth-hint { margin: 7px 0 0; color: var(--muted); font-size: .83rem; }
.auth-submit { margin-top: 19px; }
.auth-switch { display: block; margin: 14px auto 0; }
.text-button {
  min-height: 36px;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--accent);
  font-size: .9rem;
  font-weight: 650;
  cursor: pointer;
}

.text-button:hover { text-decoration: underline; }
.account-error { margin-bottom: 16px; }

.upload-guide {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  gap: 12px;
  margin-bottom: 8px;
  pointer-events: none;
}

.upload-mascot { position: relative; flex: none; width: 110px; height: 92px; }
.mascot-head, .mascot-body, .mascot-bin, .mascot-paper { position: absolute; display: block; }
.mascot-head {
  top: 10px;
  left: 12px;
  width: 52px;
  height: 45px;
  border: 2px solid #6348a1;
  border-radius: 17px 17px 15px 15px;
  background: #e0d5fa;
  transform: rotate(-7deg);
}
.mascot-head::before, .mascot-head::after, .mascot-body::after, .mascot-bin::after { position: absolute; content: ""; }
.mascot-head::before { top: 14px; left: 12px; width: 5px; height: 6px; border-radius: 50%; background: #4a2d7b; box-shadow: 16px 0 #4a2d7b; }
.mascot-head::after { top: 24px; left: 16px; width: 15px; height: 8px; border-bottom: 2px solid #4a2d7b; border-radius: 50%; }
.mascot-body { top: 49px; left: 19px; width: 43px; height: 31px; border-radius: 12px 12px 8px 8px; background: #7657b3; }
.mascot-body::after { top: 4px; left: 35px; width: 32px; height: 9px; border-radius: 8px; background: #7657b3; transform: rotate(-22deg); }
.mascot-bin {
  top: 48px;
  left: 69px;
  width: 33px;
  height: 23px;
  transform: rotate(22deg);
  transform-origin: 27% 28%;
  border: 2px solid #60489a;
  border-top: 4px solid #60489a;
  border-radius: 3px 4px 8px 8px;
  background: #b6a1e5;
  animation: tip-bin 1.7s ease-in-out both;
}
.mascot-bin::after { top: 4px; left: 10px; height: 8px; border-left: 2px solid #8166ba; box-shadow: 6px 0 #8166ba; }
.mascot-paper {
  top: 56px;
  left: 95px;
  width: 10px;
  height: 14px;
  border: 1px solid #9278c8;
  border-radius: 2px;
  background: #fff;
  opacity: 0;
  animation: papers-into-upload 1.7s ease-in both;
}
.mascot-paper:nth-last-child(2) { animation-delay: .16s; }
.mascot-paper:last-child { animation-delay: .34s; }
.mascot-bubble {
  position: relative;
  align-self: center;
  max-width: 425px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 13px;
  background: var(--accent-soft);
  color: var(--ink);
  font-size: .88rem;
  line-height: 1.46;
}
.upload-guide .mascot-bubble::before {
  position: absolute;
  top: 45%;
  right: 100%;
  border: 7px solid transparent;
  border-right-color: var(--accent-soft);
  content: "";
}
.transcription-estimate { margin: 16px auto 0; text-align: left; }

@keyframes tip-bin {
  0%, 100% { transform: rotate(22deg); }
  42%, 71% { transform: rotate(75deg); }
}
@keyframes papers-into-upload {
  0%, 34% { opacity: 0; transform: translate(-2px, 0) rotate(12deg); }
  44% { opacity: 1; }
  81% { opacity: 1; transform: translate(10px, 45px) rotate(49deg); }
  100% { opacity: 0; transform: translate(17px, 60px) rotate(68deg); }
}

.drop-zone {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  width: 100%;
  min-height: 220px;
  padding: 24px 12px;
  border: 1.5px dashed #b6addc;
  border-radius: 16px;
  background: #faf9ff;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.drop-zone:hover, .drop-zone.is-dragging {
  border-color: var(--accent);
  background: #f3efff;
}

.illustration {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 15px;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
}

.upload-icon {
  position: relative;
  width: 22px;
  height: 7px;
  margin-top: 16px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 4px 4px;
}

.upload-icon::before, .upload-icon::after {
  position: absolute;
  left: 50%;
  content: "";
}

.upload-icon::before {
  bottom: 8px;
  width: 2px;
  height: 16px;
  border-radius: 2px;
  background: currentColor;
  transform: translateX(-50%);
}

.upload-icon::after {
  top: -18px;
  width: 9px;
  height: 9px;
  border: solid currentColor;
  border-width: 2px 0 0 2px;
  transform: translateX(-50%) rotate(45deg);
}

.drop-title {
  font-size: 1.12rem;
  font-weight: 720;
}

.drop-hint, .drop-formats {
  margin-top: 5px;
  color: var(--muted);
  font-size: .91rem;
}

.drop-formats {
  margin-top: 13px;
  font-size: .79rem;
}

.file-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.file-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}

.file-details { flex: 1; min-width: 0; }
.file-name { display: block; font-weight: 650; overflow-wrap: anywhere; }
.file-size { display: block; margin-top: 2px; color: var(--muted); font-size: .84rem; }

.audio-preview { margin-top: 13px; }
.audio-preview audio { display: block; width: 100%; }
.audio-note { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.5; }
.status-audio { width: min(100%, 390px); margin: 16px auto 0; }

.icon-button {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover { background: var(--page); color: var(--ink); }

.icon-button::before, .icon-button::after {
  position: absolute;
  top: calc(50% - 1px);
  left: calc(50% - 7px);
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
}

.icon-button::after { transform: rotate(-45deg); }

.upload-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px 18px;
  margin-top: 18px;
}

.upload-limits {
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 45px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: .91rem;
  font-weight: 680;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s, border-color .15s;
}

.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-hover); }
.button-primary:disabled { background: #ebe8f6; color: #5f5977; cursor: default; }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--ink); }
.button-secondary:hover { border-color: #bfb3e6; background: #faf8ff; }
.button-secondary:disabled { border-color: var(--line); background: var(--page); color: var(--muted); cursor: default; }

.error, .notice {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 9px;
  font-size: .91rem;
  overflow-wrap: anywhere;
}

.error { background: #fff0f2; color: var(--error); }
.notice { background: var(--page); color: var(--muted); }

.status-panel { padding-block: 36px; text-align: center; }
.cancel-button { margin-top: 20px; }
.activity-icon { gap: 3px; }
.activity-icon i { animation: pulse 1.1s ease-in-out both; }
.activity-icon i:nth-child(2n) { animation-delay: .15s; }
.activity-icon i:nth-child(3) { animation-delay: .3s; }

@keyframes pulse {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.3); }
}

.speech-animation {
  position: relative;
  width: 153px;
  height: 72px;
  margin: 0 auto 15px;
  overflow: hidden;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
}

.speech-face {
  position: absolute;
  top: 14px;
  left: 16px;
  width: 42px;
  height: 44px;
  border: 1px solid #9777cf;
  border-radius: 50% 46% 52% 47%;
  background: #d3b9f4;
  transform: rotate(-7deg);
}

.speech-face::before {
  position: absolute;
  top: -3px;
  left: 3px;
  width: 30px;
  height: 10px;
  border-radius: 80% 60% 20% 30%;
  background: #7a57b2;
  content: "";
}

.speech-eye {
  position: absolute;
  top: 15px;
  left: 17px;
  width: 4px;
  height: 5px;
  border-radius: 50%;
  background: #412564;
  box-shadow: 10px 0 #412564;
}

.speech-mouth {
  position: absolute;
  top: 26px;
  left: 21px;
  width: 14px;
  height: 8px;
  border-radius: 30% 30% 60% 60%;
  background: #573580;
  animation: speaking 3s ease-in-out both;
}

.speech-sheet {
  position: absolute;
  right: 15px;
  bottom: 13px;
  width: 26px;
  height: 33px;
  transform: rotate(9deg);
  border: 1px solid #bba8e6;
  border-radius: 4px;
  background: #fff;
}

.speech-sheet::after {
  position: absolute;
  top: 10px;
  left: 5px;
  width: 13px;
  height: 1px;
  background: #a38dd0;
  box-shadow: 0 5px #a38dd0, 0 10px #a38dd0;
  content: "";
}

.speech-word {
  position: absolute;
  top: 33px;
  left: 57px;
  color: #694ab0;
  font-size: .74rem;
  font-weight: 760;
  line-height: 1;
  opacity: 0;
  animation: words-to-paper 1.8s linear both;
}

.speech-word:nth-last-child(2) { animation-delay: .6s; }
.speech-word:last-child { animation-delay: 1.2s; }

@keyframes speaking {
  0%, 18%, 38%, 58%, 78%, 100% { transform: scaleY(.4); }
  8%, 28%, 48%, 68%, 86% { transform: scaleY(1.2); }
}

@keyframes words-to-paper {
  0% { opacity: 0; transform: translate(0, 0) rotate(-17deg); }
  16% { opacity: 1; }
  63% { opacity: 1; transform: translate(42px, -20px) rotate(12deg); }
  90%, 100% { opacity: 0; transform: translate(63px, 13px) rotate(24deg); }
}

h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  font-weight: 740;
  letter-spacing: -.032em;
}

.status-file, .status-detail {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.status-detail { margin-top: 13px; }

progress {
  display: block;
  width: min(100%, 340px);
  height: 9px;
  margin: 19px auto 0;
  border: 0;
  border-radius: 20px;
  appearance: none;
  background: var(--accent-soft);
  color: var(--accent);
}

progress::-webkit-progress-bar { border-radius: 20px; background: var(--accent-soft); }
progress::-webkit-progress-value { border-radius: 20px; background: var(--accent); }
progress::-moz-progress-bar { border-radius: 20px; background: var(--accent); }

.transcription-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, 390px);
  margin: 19px auto 0;
}

.transcription-progress progress { flex: 1; width: auto; min-width: 0; margin: 0; }
.progress-value {
  flex: none;
  min-width: 4ch;
  color: var(--accent);
  font-size: .94rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.result-header, .result-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.result-header > div { min-width: 0; }
.result-header button { flex-shrink: 0; }
#result-title { overflow-wrap: anywhere; }
.title-retry { padding-inline: 0; }
.output-title-error { margin: 0; color: var(--error); font-size: .86rem; line-height: 1.5; }

.result-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 22px;
  margin: 13px 0 0;
}

.result-metadata > div { min-width: 0; }
.result-metadata dt { color: var(--muted); font-size: .8rem; }
.result-metadata dd { margin: 2px 0 0; font-size: .92rem; font-weight: 650; overflow-wrap: anywhere; }

.translation-result {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 16px;
}

.transcript-versions { display: flex; flex-wrap: wrap; gap: 5px; }
.transcript-versions .button, #translation-action { min-height: 37px; padding: 6px 11px; }
.transcript-versions .button[aria-pressed="true"] { border-color: #d3caef; background: var(--accent-soft); color: var(--accent); }
.translation-status { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.translation-result:not([hidden]) + .transcript { margin-top: 11px; }

.transcript {
  min-height: 126px;
  max-height: 55vh;
  margin: 18px 0;
  padding: 16px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fafaff;
  font-size: 1rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.result-actions { justify-content: flex-start; }
.status-panel, .result-panel { scroll-margin-top: 16px; }

.protocol-result {
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.protocol-status { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.protocol-download { color: var(--accent); }
.protocol-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 11px; }
.protocol-work { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.protocol-meter { display: flex; flex: 1 1 155px; align-items: center; gap: 10px; min-width: 0; }
.protocol-meter progress { flex: 1; width: auto; min-width: 0; margin: 0; }
.protocol-meter progress:indeterminate {
  background: repeating-linear-gradient(120deg, var(--accent-soft), var(--accent-soft) 7px, #d9cef7 7px, #d9cef7 14px);
}
.protocol-meter progress:indeterminate::-webkit-progress-bar { background: transparent; }

.laser-scene {
  position: relative;
  flex: none;
  width: 124px;
  height: 59px;
  overflow: hidden;
  border-radius: 12px;
  background: #e8f4ef;
}
.laser-robot {
  position: absolute;
  top: 16px;
  left: 10px;
  width: 30px;
  height: 31px;
  border: 2px solid #3b7466;
  border-radius: 11px;
  background: #a9ccbf;
}
.laser-robot::before { position: absolute; top: 9px; left: 7px; width: 4px; height: 4px; border-radius: 50%; background: #245347; box-shadow: 8px 0 #245347; content: ""; }
.laser-beam { position: absolute; top: 25px; left: 36px; width: 59px; height: 3px; border-radius: 4px; background: #5da68b; opacity: 0; transform: rotate(-7deg); animation: laser-glow 2.4s ease-in-out both; }
.laser-sheet {
  position: absolute;
  top: 8px;
  right: 13px;
  width: 31px;
  height: 39px;
  transform-origin: right bottom;
  border: 1px solid #86aaa0;
  border-radius: 4px;
  background: #fff;
  animation: shrink-sheet 2.4s ease-in-out both;
}
.laser-sheet::after { position: absolute; top: 9px; left: 5px; width: 19px; height: 2px; background: #9eb9af; box-shadow: 0 6px #9eb9af, 0 12px #9eb9af; content: ""; }
@keyframes laser-glow { 0%, 100% { opacity: 0; } 15%, 75% { opacity: 1; } }
@keyframes shrink-sheet { 0%, 15% { transform: scale(1) rotate(5deg); } 75%, 100% { transform: scale(.62) rotate(5deg); } }

.protocol-result h3 { margin: 0 0 10px; font-size: 1.16rem; }
.brief-content {
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f9fbfa;
  font-size: .94rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.brief-content h4 { margin: 12px 0 4px; font-size: .94rem; }
.brief-content p, .brief-content ul, .brief-content ol { margin: 4px 0; }
.brief-content ul, .brief-content ol { padding-inline-start: 20px; }
.brief-content a { color: var(--accent); }

.history-panel { margin-top: 22px; }
.history-panel[inert] { opacity: .76; }
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.history-header .button, .history-delete {
  min-height: 36px;
  padding: 6px 11px;
  font-size: .83rem;
}

.history-note { margin: 13px 0 0; color: var(--muted); font-size: .9rem; }
.history-note:empty { display: none; }
.history-list { margin: 13px 0 0; padding: 0; list-style: none; }
.history-list:empty { margin: 0; }

.history-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.history-details { flex: 1 1 180px; min-width: 0; padding: 12px 6px; }
.history-description { min-width: 0; }
.history-name { display: block; font-size: .94rem; font-weight: 680; overflow-wrap: anywhere; }
.history-meta { display: block; margin-top: 3px; color: var(--muted); font-size: .82rem; }
.history-open {
  display: flex;
  align-items: center;
  align-self: stretch;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.history-open:hover { background: #faf8ff; }
.history-open-label { flex: none; color: var(--accent); font-size: .83rem; font-weight: 680; }
.history-open:hover .history-open-label { text-decoration: underline; }
.history-delete { flex: none; color: var(--error); }
.history-more { margin-top: 10px; }

.screen-reader-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (max-width: 460px) {
  .header-content { min-height: 60px; }
  .brand { gap: 7px; font-size: .91rem; }
  .brand-icon { width: 32px; height: 32px; }
  .model-badge { font-size: .72rem; }
  .account-bar:not([hidden]) + .model-badge { display: none; }
  .account-bar { gap: 7px; }
  .account-bar .button { padding-inline: 8px; }
  .account-email { font-size: .79rem; }
  .workspace { padding-inline: 14px; }
  .drop-zone { min-height: 192px; }
  .upload-guide { gap: 9px; }
  .upload-mascot { width: 98px; }
  .mascot-bubble { padding: 8px 10px; font-size: .84rem; }
  .upload-actions .button { width: 100%; }
  .result-actions .button { flex: 1; }
  .result-actions .button-primary { flex: 1 1 100%; }
}

@media (max-width: 340px) {
  .account-email { max-width: 22vw; }
  .header-content { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .speech-word:nth-last-child(3) { opacity: 1; transform: translate(17px, -15px); }
  .speech-word:nth-last-child(2) { opacity: 1; transform: translate(38px, -11px); }
  .mascot-paper:nth-last-child(3) { opacity: 1; transform: translate(2px, 4px) rotate(19deg); }
  .laser-sheet { transform: scale(.75) rotate(5deg); }
}
