:root {
  --bg: #f5f7fb;
  --bg-soft: #ecf1ff;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --panel-outline: rgba(54, 85, 255, 0.12);
  --accent: #3655ff;
  --accent-soft: rgba(54, 85, 255, 0.12);
  --text-strong: #172042;
  --text: #243055;
  --text-muted: #697193;
  --divider: rgba(23, 32, 66, 0.12);
  --shadow: 0 18px 48px rgba(23, 32, 66, 0.14);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 12px;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, rgba(236, 241, 255, 0.92), rgba(245, 247, 251, 0.95)),
    radial-gradient(circle at 18% -12%, rgba(54, 85, 255, 0.12), transparent 52%),
    radial-gradient(circle at 78% 0%, rgba(89, 173, 255, 0.16), transparent 58%);
  color: var(--text);
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 48px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(24px, 6vw, 48px) clamp(20px, 8vw, 80px);
}

.identity {
  display: flex;
  align-items: center;
  gap: 18px;
}

.glyph {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  font-size: 30px;
  border-radius: 20px;
  background: rgba(54, 85, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(54, 85, 255, 0.18);
  color: var(--accent);
}

.identity-copy {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product {
  font-size: clamp(1.8rem, 2.7vw, 2.4rem);
  font-weight: 700;
  color: var(--text-strong);
}

.tagline {
  margin: 0;
  color: var(--text-muted);
}

.primary-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.auth-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-wrapper {
  position: relative;
}

.login-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding-inline: 18px;
}

.login-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.login-icon path {
  transition: opacity 0.2s ease;
}

.login-button:hover .login-icon path {
  opacity: 0.9;
}

.login-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid rgba(23, 32, 66, 0.12);
  box-shadow: 0 18px 30px rgba(15, 23, 42, 0.18);
  min-width: 220px;
  z-index: 40;
}

.login-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-strong);
  border-radius: var(--radius-sm);
  font-weight: 500;
  cursor: pointer;
}

.login-menu-item:hover {
  background: rgba(54, 85, 255, 0.1);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(24px, 6vw, 56px);
  padding: 0 clamp(20px, 8vw, 80px);
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-outline);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 48px);
  backdrop-filter: blur(12px);
}

.tts-panel h1 {
  font-size: clamp(1.8rem, 2.6vw, 2.6rem);
  margin: 0 0 12px;
  color: var(--text-strong);
}

.tts-panel p {
  margin: 0;
  color: var(--text-muted);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin-bottom: 32px;
}

.meta-counters {
  display: flex;
  gap: 18px;
}

.counter {
  min-width: 140px;
  background: rgba(236, 241, 255, 0.9);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid rgba(54, 85, 255, 0.12);
}

.counter-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-strong);
}

.counter-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.status-area {
  margin-bottom: 24px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--divider);
  background: #ffffff;
  line-height: 1.6;
}

.status-area.success {
  border-color: rgba(29, 156, 112, 0.35);
  background: rgba(29, 156, 112, 0.08);
}

.status-area.error {
  border-color: rgba(225, 81, 81, 0.4);
  background: rgba(225, 81, 81, 0.08);
}

.status-area.info {
  border-color: rgba(54, 85, 255, 0.35);
  background: rgba(54, 85, 255, 0.08);
}

.hidden {
  display: none !important;
}

.tts-form {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.input-label {
  font-weight: 600;
  color: var(--text-strong);
}

textarea,
select,
input[type="text"] {
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(36, 48, 85, 0.16);
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea::placeholder,
input::placeholder {
  color: rgba(105, 113, 147, 0.6);
}

textarea:focus,
select:focus,
input:focus {
  outline: none;
  border-color: rgba(54, 85, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(54, 85, 255, 0.18);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, rgba(105, 113, 147, 0.65) 50%),
    linear-gradient(135deg, rgba(105, 113, 147, 0.65) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 3px), calc(100% - 13px) calc(50% + 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 18px;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.form-footnote {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

button {
  cursor: pointer;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  padding: 12px 22px;
  font-size: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.primary-button {
  background-color: var(--accent);
  color: #fff;
  box-shadow: 0 14px 30px rgba(54, 85, 255, 0.24);
}

.primary-button:hover {
  transform: translateY(-1px);
  background-color: #2b48e0;
  box-shadow: 0 18px 38px rgba(54, 85, 255, 0.28);
}

.secondary-button {
  background: rgba(54, 85, 255, 0.1);
  color: var(--text-strong);
  border: 1px solid rgba(54, 85, 255, 0.26);
}

.secondary-button:hover {
  background: rgba(54, 85, 255, 0.16);
}

.ghost-button {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(23, 32, 66, 0.16);
}

.ghost-button:hover {
  color: var(--text-strong);
  border-color: rgba(23, 32, 66, 0.28);
}

.meta-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--surface-strong);
  border-radius: var(--radius-lg);
  padding: 28px;
  border: 1px solid rgba(54, 85, 255, 0.08);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.player-card h2 {
  margin: 0 0 8px;
  color: var(--text-strong);
}

.quota-hint {
  margin: 0 0 12px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.player-title {
  margin: 0 0 16px;
  font-weight: 600;
  color: var(--text-strong);
}

.player-status {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

audio {
  width: 100%;
  border-radius: var(--radius-sm);
  background: rgba(236, 241, 255, 0.7);
}

.history-drawer {
  position: fixed;
  inset: 0;
  background: rgba(13, 24, 63, 0.16);
  backdrop-filter: blur(12px);
  display: grid;
  place-items: end;
  padding: clamp(20px, 8vw, 64px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 30;
}

.history-drawer.open {
  opacity: 1;
  pointer-events: auto;
}

.history-sheet {
  width: min(480px, 100%);
  background: var(--surface-strong);
  border-radius: 32px;
  border: 1px solid rgba(54, 85, 255, 0.12);
  padding: 32px;
  box-shadow: var(--shadow);
  transform: translateY(40px);
  transition: transform 0.3s ease;
}

.history-drawer.open .history-sheet {
  transform: translateY(0);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 24px;
}

.history-header h2 {
  margin: 0 0 6px;
  color: var(--text-strong);
}

.history-header p {
  margin: 0;
  color: var(--text-muted);
}

.history-list {
  max-height: min(60vh, 520px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 6px;
}

.history-item {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(54, 85, 255, 0.1);
  background: rgba(236, 241, 255, 0.65);
}

.history-title {
  margin: 0 0 6px;
  color: var(--text-strong);
  font-size: 1rem;
}

.history-meta {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.history-actions {
  display: flex;
  gap: 10px;
}

.history-footer {
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

  .meta-column {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .meta-column .card {
    flex: 1 1 280px;
  }
}

@media (max-width: 720px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .meta-counters {
    width: 100%;
    justify-content: space-between;
  }

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

  .primary-button {
    width: 100%;
  }
}
