:root {
  color-scheme: light;
  --ink: #1b2b36;
  --ink-soft: #59676d;
  --paper: #f3f0e8;
  --paper-deep: #e9e4d8;
  --card: #fffdf8;
  --line: #d9d5ca;
  --navy: #193a4b;
  --navy-hover: #102d3c;
  --orange: #ec7248;
  --orange-soft: #fff0e8;
  --green: #4b836a;
  --shadow: 0 18px 60px rgba(32, 46, 52, 0.08);
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 2%, rgba(236, 114, 72, 0.08), transparent 28rem),
    radial-gradient(circle at 95% 95%, rgba(25, 58, 75, 0.06), transparent 32rem),
    var(--paper);
}

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

button,
select {
  cursor: pointer;
}

button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(236, 114, 72, 0.35);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

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

.page-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 80px);
}

.site-header {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(27, 43, 54, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 13px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--card);
  background: var(--navy);
  border-radius: 14px 14px 14px 4px;
  box-shadow: 0 7px 16px rgba(25, 58, 75, 0.2);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
}

.brand-copy { line-height: 1; }

.brand-copy strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.header-actions,
.user-menu {
  display: flex;
  align-items: center;
}

.header-actions {
  gap: 10px;
}

.login-button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  box-shadow: 0 4px 12px rgba(27, 43, 54, 0.05);
}

.login-button:hover {
  border-color: #bdb7aa;
  box-shadow: 0 6px 16px rgba(27, 43, 54, 0.09);
}

.login-button svg {
  width: 17px;
  height: 17px;
}

.login-button svg path:nth-child(1) { fill: #4285f4; }
.login-button svg path:nth-child(2) { fill: #34a853; }
.login-button svg path:nth-child(3) { fill: #fbbc05; }
.login-button svg path:nth-child(4) { fill: #ea4335; }

.user-menu {
  gap: 8px;
  height: 42px;
  padding: 4px 5px 4px 4px;
  background: rgba(255, 253, 248, 0.82);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.user-menu img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  background: var(--paper-deep);
  border-radius: 50%;
}

.user-menu span {
  max-width: 110px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu button {
  height: 30px;
  padding: 0 9px;
  color: #77817e;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 10px;
}

.user-menu button:hover {
  color: #a14636;
  background: #f2eee6;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.78fr);
  gap: clamp(32px, 4.5vw, 68px);
  padding: 36px 0 56px;
}

.composer-section {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--orange);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.composer-card {
  padding: clamp(24px, 3.2vw, 38px);
  background: var(--card);
  border: 1px solid rgba(217, 213, 202, 0.9);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.composer-meta,
.voice-row,
.history-header,
.history-item-footer,
.history-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-label {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.byte-count {
  color: #8a928f;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.byte-count.over-limit {
  color: #b74c39;
  font-weight: 700;
}

.textarea-wrap {
  position: relative;
  margin-top: 13px;
}

textarea {
  display: block;
  width: 100%;
  height: clamp(240px, 38vh, 420px);
  min-height: 190px;
  padding: 22px 52px 22px 22px;
  resize: none;
  color: var(--ink);
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 18px;
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: clamp(17px, 1.5vw, 20px);
  line-height: 1.8;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea::placeholder {
  color: #a8aca7;
}

textarea:hover {
  border-color: #c6c0b3;
}

textarea:focus {
  outline: none;
  background: #fffefa;
  border-color: rgba(25, 58, 75, 0.58);
  box-shadow: 0 0 0 4px rgba(25, 58, 75, 0.07);
}

.clear-input-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #8c928e;
  background: #efede6;
  border: 0;
  border-radius: 50%;
}

.clear-input-button:hover {
  color: var(--ink);
  background: #e4e0d6;
}

.clear-input-button svg,
.icon-button svg,
.history-search svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-row {
  gap: 22px;
  margin-top: 18px;
}

.voice-field {
  flex: 1;
  min-width: 0;
}

.select-wrap {
  position: relative;
  margin-top: 0;
}

.voice-avatar {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 10px;
  display: grid;
  place-items: center;
  width: 33px;
  height: 33px;
  color: var(--navy);
  background: #e9eef0;
  border-radius: 10px;
  font-family: "Yu Mincho", serif;
  font-size: 15px;
  transform: translateY(-50%);
  pointer-events: none;
}

select {
  width: 100%;
  height: 53px;
  padding: 0 42px 0 54px;
  color: var(--ink);
  appearance: none;
  background: #faf8f2;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 13px;
  font-weight: 650;
}

select:hover,
select:focus {
  border-color: rgba(25, 58, 75, 0.55);
}

select:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(25, 58, 75, 0.07);
}

.chevron {
  position: absolute;
  top: 50%;
  right: 15px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--ink-soft);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-50%);
  pointer-events: none;
}

.speak-button {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 168px;
  height: 53px;
  padding: 0 24px;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(25, 58, 75, 0.18);
  font-size: 14px;
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.speak-button:hover:not(:disabled) {
  background: var(--navy-hover);
  box-shadow: 0 10px 25px rgba(25, 58, 75, 0.24);
  transform: translateY(-2px);
}

.speak-button:active:not(:disabled) {
  transform: translateY(0);
}

.speak-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.button-icon {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
}

.speaker-icon {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.loading-bars {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 18px;
}

.loading-bars i {
  width: 3px;
  height: 7px;
  background: currentColor;
  border-radius: 3px;
  animation: loading-wave 700ms ease-in-out infinite alternate;
}

.loading-bars i:nth-child(2) {
  height: 15px;
  animation-delay: 160ms;
}

.loading-bars i:nth-child(3) {
  height: 10px;
  animation-delay: 320ms;
}

.speak-button.is-loading .speaker-icon {
  display: none;
}

.speak-button.is-loading .loading-bars {
  display: flex;
}

@keyframes loading-wave {
  to { transform: scaleY(0.45); }
}

.player-panel {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: min(660px, calc(100vw - 48px));
  margin: 0;
  padding: 14px 16px 16px;
  background: rgba(246, 247, 242, 0.97);
  border: 1px solid rgba(194, 204, 196, 0.94);
  border-radius: 24px;
  box-shadow: 0 22px 56px rgba(19, 43, 53, 0.22), 0 5px 16px rgba(19, 43, 53, 0.11);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.player-panel audio {
  display: none;
}

.player-top-row,
.player-bottom-row {
  display: grid;
  align-items: center;
  gap: 14px;
}

.player-top-row {
  grid-template-columns: 50px minmax(0, 1fr) 50px;
}

.player-bottom-row {
  grid-template-columns: 58px minmax(0, 1fr) 58px;
  margin-top: 12px;
}

.now-playing {
  min-width: 0;
  text-align: center;
}

.now-playing strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-time {
  display: block;
  margin-top: 2px;
  color: #7d8984;
  font-size: 10px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.transport-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.transport-button:active {
  transform: scale(0.94);
}

.seek-button {
  gap: 1px;
  width: 50px;
  height: 50px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #d2d9d2;
  font-size: 10px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.seek-button:hover {
  color: var(--orange);
  background: #fff;
  border-color: #c6cec6;
}

.seek-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.player-center-controls {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  justify-self: center;
  min-width: 168px;
  height: 44px;
  padding: 0 14px;
  background: #e6e8e2;
  border: 1px solid rgba(202, 210, 202, 0.88);
  border-radius: 999px;
}

.repeat-button {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 4px;
  color: #71807a;
  border: 0;
  background: transparent;
  font-size: 10px;
  font-weight: 850;
}

.repeat-button:hover,
.repeat-button.is-active {
  color: var(--orange);
}

.repeat-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-divider {
  width: 1px;
  height: 22px;
  background: #c9d0c9;
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 5px;
}

.speed-control span {
  color: #7b8782;
  font-size: 9px;
  font-weight: 800;
}

.speed-control select {
  width: 54px;
  height: 32px;
  padding: 0 16px 0 4px;
  color: var(--ink);
  background-color: transparent;
  border: 0;
  font-size: 11px;
  font-weight: 850;
  background-image:
    linear-gradient(45deg, transparent 50%, #73807b 50%),
    linear-gradient(135deg, #73807b 50%, transparent 50%);
  background-position:
    calc(100% - 8px) 14px,
    calc(100% - 5px) 14px;
  background-repeat: no-repeat;
  background-size: 3px 3px, 3px 3px;
}

.stop-button,
.playback-toggle {
  position: relative;
  z-index: 1;
  min-width: 58px;
  max-width: 58px;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  color: #fff;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(28, 53, 62, 0.18);
}

.stop-button {
  grid-column: 1;
  justify-self: start;
  background: linear-gradient(145deg, #ef805a, #e65843);
}

.playback-toggle {
  grid-column: 3;
  justify-self: end;
  background: linear-gradient(145deg, #eaa15a, var(--orange));
}

.stop-button:hover,
.playback-toggle:hover {
  filter: brightness(1.04);
}

.playback-toggle svg {
  width: 25px;
  height: 25px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stop-icon {
  display: block;
  width: 18px;
  height: 18px;
  background: #fffdf8;
  border-radius: 3px;
}

.playback-toggle .play-icon {
  display: block;
}

.pause-icon {
  display: none;
  fill: none !important;
}

.playback-toggle.is-playing .play-icon {
  display: none;
}

.playback-toggle.is-playing .pause-icon {
  display: block;
}

.message {
  margin-top: 16px;
  padding: 12px 15px;
  color: #9d3f32;
  background: #fff0ed;
  border: 1px solid #f2ccc5;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.6;
}

.history-panel {
  align-self: start;
  position: sticky;
  top: 20px;
  min-height: 0;
  max-height: calc(100dvh - 112px);
  display: flex;
  flex-direction: column;
  padding: clamp(24px, 3vw, 34px);
  background: rgba(232, 227, 215, 0.58);
  border: 1px solid rgba(207, 201, 187, 0.8);
  border-radius: 30px;
  overflow: hidden;
}

.history-header {
  flex: 0 0 auto;
}

h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Yu Mincho", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.history-tools {
  gap: 10px;
  margin-top: 16px;
}

.history-search {
  position: relative;
  flex: 1;
}

.history-search svg {
  position: absolute;
  top: 50%;
  left: 12px;
  color: #89918e;
  transform: translateY(-50%);
  pointer-events: none;
}

.history-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 38px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.6);
  border: 1px solid #d3cec1;
  border-radius: 11px;
  font-size: 12px;
}

.history-search input:focus {
  outline: none;
  background: var(--card);
  border-color: #9ea9a8;
}

.history-list {
  min-height: 0;
  display: grid;
  gap: 11px;
  margin-top: 18px;
  padding-right: 5px;
  overflow-y: auto;
  scrollbar-color: #b9b4a9 transparent;
  scrollbar-width: thin;
}

.history-item {
  padding: 17px;
  background: rgba(255, 253, 248, 0.86);
  border: 1px solid rgba(209, 204, 192, 0.88);
  border-radius: 16px;
  transition: background-color 150ms ease, border-color 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.history-item.is-current {
  background: var(--orange-soft);
  border-color: rgba(236, 114, 72, 0.52);
  box-shadow: inset 4px 0 0 var(--orange), 0 7px 20px rgba(42, 52, 55, 0.06);
}

.history-item.is-current:hover {
  border-color: rgba(236, 114, 72, 0.68);
}

.history-item.is-current .history-item-footer {
  border-top-color: rgba(236, 114, 72, 0.2);
}

.history-item:hover {
  border-color: #beb8aa;
  box-shadow: 0 7px 20px rgba(42, 52, 55, 0.06);
  transform: translateY(-1px);
}

.history-text {
  width: 100%;
  display: -webkit-box;
  padding: 0;
  overflow: hidden;
  color: var(--ink);
  background: none;
  border: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.7;
  text-align: left;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.history-item-footer {
  gap: 10px;
  margin-top: 13px;
  padding-top: 11px;
  border-top: 1px solid #e9e5dc;
}

.history-info {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #858d8a;
  font-size: 9px;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.history-more {
  position: relative;
}

.mobile-history-more {
  display: none;
}

.history-more summary {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  color: #7c8682;
  border-radius: 8px;
  list-style: none;
  cursor: pointer;
}

.history-more summary::-webkit-details-marker {
  display: none;
}

.history-more summary:hover,
.history-more[open] summary {
  color: var(--navy);
  background: #eeece5;
}

.history-more summary svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.history-more .delete-button {
  position: absolute;
  z-index: 4;
  right: 0;
  bottom: calc(100% + 7px);
  width: max-content;
  min-width: 92px;
  height: 38px;
  padding: 0 13px;
  color: #a14636;
  background: #fffaf7;
  border: 1px solid #e1c6bd;
  border-radius: 11px;
  box-shadow: 0 9px 24px rgba(61, 40, 34, 0.16);
  font-size: 11px;
  font-weight: 750;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  padding: 0;
  color: #7c8682;
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.icon-button:hover {
  color: var(--navy);
  background: #eeece5;
}

.delete-button:hover {
  color: #a14636;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 430px;
  padding: 32px 12px;
  text-align: center;
}

.empty-illustration {
  position: relative;
  width: 132px;
  height: 100px;
  margin-bottom: 25px;
}

.empty-illustration span {
  position: absolute;
  z-index: 1;
  top: 3px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  color: var(--orange);
  background: rgba(255, 253, 248, 0.75);
  border: 1px solid rgba(202, 195, 181, 0.85);
  border-radius: 50% 50% 50% 12px;
  font-family: "Yu Mincho", serif;
  font-size: 26px;
  transform: translateX(-50%) rotate(-5deg);
}

.empty-illustration svg {
  position: absolute;
  bottom: 0;
  left: 5px;
  width: 120px;
  height: 88px;
  stroke: #c8c2b5;
  stroke-width: 1.2;
  stroke-linecap: round;
}

.empty-state h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Yu Mincho", Georgia, serif;
  font-size: 18px;
  font-weight: 600;
}

.empty-state p {
  max-width: 230px;
  margin: 9px 0 0;
  color: #7f8985;
  font-size: 11px;
  line-height: 1.65;
}

.empty-login-button {
  height: 38px;
  margin-top: 18px;
  padding: 0 17px;
  color: #fff;
  background: var(--navy);
  border: 0;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 750;
}

.empty-login-button:hover {
  background: var(--navy-hover);
}

.login-dialog {
  width: min(430px, calc(100vw - 32px));
  padding: 42px 38px 34px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 28px 90px rgba(18, 37, 47, 0.25);
  text-align: center;
}

.login-dialog::backdrop {
  background: rgba(20, 34, 41, 0.5);
  backdrop-filter: blur(5px);
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #7d8783;
  background: #f0ede6;
  border: 0;
  border-radius: 50%;
}

.dialog-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.dialog-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  color: var(--orange);
  background: var(--orange-soft);
  border-radius: 18px 18px 18px 6px;
  font-family: "Yu Mincho", serif;
  font-size: 24px;
}

.login-dialog .eyebrow {
  margin-bottom: 6px;
}

.login-dialog h2 {
  font-size: 28px;
}

.login-dialog > p:not(.eyebrow):not(.dialog-error) {
  margin: 14px auto 22px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.75;
}

.google-signin-button {
  min-height: 44px;
  display: flex;
  justify-content: center;
}

.dialog-error {
  margin: 14px 0 0;
  padding: 10px;
  color: #9d3f32;
  background: #fff0ed;
  border-radius: 10px;
  font-size: 11px;
}

.login-dialog small {
  display: block;
  margin-top: 20px;
  color: #969c98;
  font-size: 9px;
}

.no-results {
  padding: 50px 12px;
  color: #7f8985;
  font-size: 12px;
  text-align: center;
}

.mobile-dock,
.mobile-user-panel,
.mobile-panel-backdrop,
.mobile-panel-close {
  display: none;
}

@media (min-width: 981px) {
  body.has-floating-player {
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: 0;
    overflow: hidden;
  }

  body.has-floating-player .page-shell {
    height: 100dvh;
    min-height: 0;
  }

  body.has-floating-player .app-grid {
    height: calc(100dvh - 76px);
    align-items: stretch;
    padding: 28px 0 188px;
    overflow: hidden;
  }

  body.has-floating-player .composer-section,
  body.has-floating-player .history-panel {
    min-height: 0;
    height: 100%;
  }

  body.has-floating-player .composer-card {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 24px 28px;
    overflow: hidden;
  }

  body.has-floating-player .composer-meta,
  body.has-floating-player .voice-row,
  body.has-floating-player .message {
    flex: 0 0 auto;
  }

  body.has-floating-player .textarea-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    margin-top: 10px;
  }

  body.has-floating-player textarea {
    height: 100%;
    min-height: 0;
  }

  body.has-floating-player .voice-row {
    margin-top: 16px;
  }

  body.has-floating-player .history-panel {
    position: static;
    align-self: stretch;
    max-height: none;
    padding: 22px 24px;
  }

  body.has-floating-player .history-list {
    flex: 1 1 auto;
  }
}

@media (max-width: 980px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .history-panel {
    position: static;
    min-height: 520px;
    max-height: none;
  }

  .history-list {
    max-height: 620px;
  }
}
@media (max-width: 620px) {
  :root {
    --mobile-dock-height: 64px;
    --mobile-dock-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    --mobile-player-clearance: 154px;
  }

  html,
  body,
  body.has-floating-player {
    height: 100dvh;
    min-height: 100dvh;
    padding-bottom: 0;
    overflow: hidden;
  }

  body.mobile-panel-open {
    overflow: hidden;
  }

  .page-shell {
    width: 100%;
    min-height: 0;
    padding: 0;
  }

  .site-header {
    display: none;
  }

  .app-grid {
    display: block;
    padding: 0;
  }

  .composer-section {
    min-height: 0;
  }

  .composer-card {
    height: calc(100dvh - var(--mobile-dock-height) - var(--mobile-dock-bottom) - 8px);
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 12px;
    background: rgba(255, 253, 248, 0.72);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  body.has-floating-player .composer-card {
    padding-bottom: calc(12px + var(--mobile-player-clearance));
  }

  .composer-meta {
    flex: 0 0 auto;
    min-height: 24px;
  }

  .textarea-wrap {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    margin-top: 6px;
  }

  textarea {
    height: 100%;
    min-height: 0;
    padding: 14px 42px 14px 14px;
    resize: none;
    border-radius: 14px;
    font-size: 18px;
    line-height: 1.72;
  }

  .clear-input-button {
    top: 10px;
    right: 10px;
  }

  .voice-row {
    flex: 0 0 auto;
    align-items: stretch;
    flex-direction: row;
    gap: 8px;
    margin-top: 9px;
  }

  .voice-field .field-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .select-wrap {
    margin-top: 0;
  }

  select {
    height: 48px;
  }

  .speak-button {
    align-self: auto;
    min-width: 116px;
    height: 48px;
    padding: 0 14px;
  }

  .message {
    flex: 0 0 auto;
    margin-top: 8px;
  }

  .player-panel {
    z-index: 35;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-dock-bottom) + 10px);
    width: calc(100vw - 24px);
    padding: 12px 14px 14px;
    border-radius: 22px;
  }

  .player-top-row {
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    gap: 10px;
  }

  .player-bottom-row {
    grid-template-columns: 56px minmax(0, 1fr) 56px;
    gap: 10px;
    margin-top: 10px;
  }

  .now-playing strong {
    font-size: 12px;
  }

  .seek-button {
    width: 48px;
    min-width: 48px;
    height: 48px;
  }

  .player-center-controls {
    min-width: 0;
    width: 100%;
    max-width: 176px;
    height: 42px;
    gap: 8px;
    padding: 0 10px;
  }

  .repeat-button {
    gap: 4px;
  }

  .stop-button,
  .playback-toggle {
    min-width: 56px;
    max-width: 56px;
    width: 56px;
    height: 56px;
    flex-basis: 56px;
  }

  .speed-control select {
    width: 52px;
    height: 32px;
  }

  .playback-toggle svg {
    width: 24px;
    height: 24px;
  }

  .history-panel {
    align-self: stretch;
    position: fixed;
    z-index: 30;
    inset: 0 0 calc(var(--mobile-dock-height) + var(--mobile-dock-bottom) + 8px);
    min-height: 0;
    max-height: none;
    height: calc(100dvh - var(--mobile-dock-height) - var(--mobile-dock-bottom) - 8px);
    padding: 10px 12px 12px;
    background: rgba(255, 253, 248, 0.98);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transform: translateX(18px);
    transition: opacity 160ms ease, transform 160ms ease;
  }

  .history-panel.mobile-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
  }

  .history-header {
    display: none;
  }

  .history-tools {
    margin-top: 0;
    padding-right: 0;
  }

  .history-list {
    flex: 1 1 auto;
    max-height: none;
    margin-top: 12px;
  }

  body.has-floating-player .history-list {
    padding-bottom: var(--mobile-player-clearance);
    scroll-padding-bottom: var(--mobile-player-clearance);
  }

  .history-item {
    padding: 14px;
  }

  .history-text {
    line-height: 1.6;
    -webkit-line-clamp: 3;
  }

  .history-item.is-expanded .history-text {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
  }

  .history-item-footer {
    margin-top: 10px;
    padding-top: 9px;
  }

  .history-actions {
    gap: 8px;
  }

  .desktop-delete-button {
    display: none;
  }

  .mobile-history-more {
    display: block;
  }

  .replay-button {
    width: 44px;
    height: 44px;
    color: #fff;
    background: var(--navy);
    border-radius: 14px;
  }

  .replay-button:hover {
    color: #fff;
    background: var(--navy-hover);
  }

  .replay-button svg {
    width: 22px;
    height: 22px;
  }

  .history-more summary {
    width: 40px;
    height: 40px;
    background: rgba(255, 253, 248, 0.72);
    border: 1px solid #d8d3c7;
    border-radius: 13px;
  }

  .mobile-panel-close {
    position: absolute;
    z-index: 2;
    top: 14px;
    right: 14px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--ink-soft);
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(202, 198, 186, 0.9);
    border-radius: 11px;
  }

  .mobile-panel-close svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .mobile-panel-backdrop {
    position: fixed;
    z-index: 45;
    inset: 0;
    display: block;
    background: rgba(19, 35, 42, 0.34);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }

  .mobile-user-panel {
    position: fixed;
    z-index: 52;
    right: 12px;
    bottom: calc(var(--mobile-dock-height) + var(--mobile-dock-bottom) + 10px);
    left: 12px;
    display: block;
    padding: 22px 18px 18px;
    background: rgba(255, 253, 248, 0.98);
    border: 1px solid rgba(207, 201, 187, 0.92);
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(18, 35, 42, 0.28);
    opacity: 0;
    pointer-events: none;
    transform: translateY(24px) scale(0.98);
    transition: opacity 180ms ease, transform 180ms ease;
  }

  .mobile-user-panel.mobile-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .mobile-user-panel h2 {
    padding-right: 40px;
  }

  .mobile-user-guest {
    display: grid;
    justify-items: center;
    margin-top: 20px;
    padding: 20px 14px 8px;
    text-align: center;
  }

  .mobile-user-placeholder {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin-bottom: 13px;
    color: var(--navy);
    background: #e9eef0;
    border-radius: 19px;
  }

  .mobile-user-placeholder svg {
    width: 29px;
    height: 29px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
  }

  .mobile-user-guest > strong {
    font-size: 16px;
  }

  .mobile-user-guest p {
    max-width: 280px;
    margin: 9px 0 16px;
    color: var(--ink-soft);
    font-size: 12px;
    line-height: 1.7;
  }

  .mobile-login-button,
  .mobile-logout-button {
    height: 44px;
    padding: 0 18px;
    border-radius: 13px;
    font-size: 12px;
    font-weight: 750;
  }

  .mobile-login-button {
    color: #fff;
    background: var(--navy);
    border: 0;
  }

  .mobile-user-card {
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 13px;
    margin-top: 20px;
    padding: 16px;
    background: #f4f1e9;
    border: 1px solid var(--line);
    border-radius: 18px;
  }

  .mobile-user-card:not([hidden]) {
    display: grid;
  }

  .mobile-user-card img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    background: #e9eef0;
    border-radius: 18px;
  }

  .mobile-user-card > div {
    min-width: 0;
    display: grid;
    gap: 4px;
  }

  .mobile-user-card strong,
  .mobile-user-card span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-user-card strong {
    font-size: 15px;
  }

  .mobile-user-card span {
    color: var(--ink-soft);
    font-size: 11px;
  }

  .mobile-logout-button {
    grid-column: 1 / -1;
    margin-top: 5px;
    color: #9d4939;
    background: #fff7f3;
    border: 1px solid #e5c9bf;
  }

  .mobile-dock {
    position: fixed;
    z-index: 60;
    right: 12px;
    bottom: var(--mobile-dock-bottom);
    left: 12px;
    height: var(--mobile-dock-height);
    display: flex;
    align-items: flex-start;
    padding: 6px;
    background: rgba(255, 253, 248, 0.96);
    border: 1px solid rgba(193, 189, 179, 0.9);
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(26, 43, 50, 0.17);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
  }

  .mobile-tabs {
    min-width: 0;
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .mobile-tab {
    position: relative;
    height: 50px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 3px;
    padding: 0;
    color: #7e8885;
    background: transparent;
    border: 0;
    border-radius: 13px;
    font-size: 9px;
    font-weight: 750;
  }

  .mobile-tab.is-active {
    color: var(--navy);
    background: #edf1ef;
  }

  .mobile-tab > svg,
  .mobile-tab-user-icon,
  .mobile-tab-user-icon > svg,
  .mobile-tab-user-icon > img,
  .mobile-tab-user-icon > b {
    width: 22px;
    height: 22px;
  }

  .mobile-tab > svg,
  .mobile-tab-user-icon > svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-tab-user-icon {
    display: block;
  }

  .mobile-tab-user-icon > img {
    display: block;
    object-fit: cover;
    border-radius: 50%;
  }

  .mobile-tab.has-user-identity .mobile-tab-user-icon > svg {
    display: none;
  }

  .mobile-tab-user-icon > b {
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--navy);
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
  }

  .login-dialog {
    padding: 38px 24px 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
