* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0faf3;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.page-content {
  --edge: clamp(10px, 3.2vw, 28px);
  padding: clamp(8px, 1.8vw, 14px) var(--edge) clamp(12px, 2.2vw, 20px);
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  box-sizing: border-box;
}

.app-header {
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.app-logo {
  width: 64px;
  height: 64px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

.auth-corner-btn {
  flex-shrink: 0;
  max-width: min(200px, 46vw);
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #b8dfc4;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #027525;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.auth-corner-btn:hover {
  background: #f8fcf9;
}

.auth-corner-btn:active {
  opacity: 0.92;
}

.auth-corner-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.auth-corner-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auth modal — above city picker */
.auth-modal[hidden] {
  display: none !important;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.auth-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 25, 0.45);
}

.auth-modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  padding: 14px 16px 20px;
}

.auth-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.auth-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e3d2e;
}

.auth-tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #bccac2;
  background: #f5faf7;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: #3d7a55;
  cursor: pointer;
}

.auth-tab.is-active {
  background: #027525;
  border-color: #027525;
  color: #f0faf3;
}

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

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #5a9970;
}

.auth-field-label {
  text-transform: uppercase;
  letter-spacing: 0.35px;
  font-size: 11px;
}

.auth-field input {
  border: 1px solid #bccac2;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  color: #1e3d2e;
}

.auth-field input:focus {
  outline: 2px solid #9dd4b4;
  outline-offset: 0;
}

.auth-form-message {
  font-size: 14px;
  line-height: 1.4;
  min-height: 1.2em;
  color: #a33;
}

.auth-form-message.is-ok {
  color: #027525;
}

.auth-primary-btn {
  margin-top: 4px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 12px;
  background: #027525;
  color: #f0faf3;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.auth-primary-btn:hover {
  opacity: 0.95;
}

.auth-primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Don't set display on logged-in pane without :not([hidden]) — it overrides the [hidden] attribute. */
.auth-modal-logged-in:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-modal-guest[hidden],
.auth-modal-logged-in[hidden] {
  display: none !important;
}

.auth-signed-in-intro {
  font-size: 13px;
  font-weight: 600;
  color: #5a9970;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.auth-signed-in-email {
  font-size: 15px;
  font-weight: 700;
  color: #1e3d2e;
  word-break: break-all;
}

/* Search — mirrors app/searchBar */
.search-bar {
  height: 52px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid #b8dfc4;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 16px;
  color: #027525;
  outline: none;
  font-family: inherit;
  min-width: 0;
}

.search-input::placeholder {
  color: #6aaa82;
}

.clear-btn {
  background: none;
  border: none;
  padding: 4px 0 4px 8px;
  cursor: pointer;
  font-size: 15px;
  color: #6aaa82;
  font-weight: 600;
  flex-shrink: 0;
}

.clear-btn:hover {
  color: #027525;
}

#home-view,
#results-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#results-view[hidden],
#listen-player[hidden] {
  display: none !important;
}

#results-view:not([hidden]) {
  flex: 1;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
}

#home-view.hidden {
  display: none !important;
}

.results-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.results-header {
  font-size: 13px;
  font-weight: 700;
  color: #5a9970;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}

.results-hint {
  margin-bottom: 8px;
  color: #3d7a55;
}

.middle-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  margin-top: clamp(14px, 3vw, 20px);
  gap: clamp(10px, 2vw, 14px);
  min-width: 0;
}

.recent-square {
  width: 100%;
  min-height: 168px;
  height: 100%;
  min-width: 0;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #b8dfc4;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  cursor: pointer;
  font: inherit;
  transition: opacity 0.15s ease;
  appearance: none;
  -webkit-appearance: none;
}

.recent-square:disabled {
  cursor: default;
  opacity: 1;
}

.recent-square:not(:disabled):active {
  opacity: 0.85;
}

.city-panel {
  min-width: 0;
  min-height: 168px;
  height: 100%;
  border-radius: 16px;
  border: none;
  background: #027525;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  font: inherit;
  text-align: left;
  appearance: none;
}

.city-panel:hover {
  filter: brightness(1.06);
}

.city-panel:active {
  opacity: 0.93;
}

.upload-city-row[hidden],
.upload-block[hidden] {
  display: none !important;
}

.upload-city-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #b8dfc4;
  background: #f9fdfb;
}

.upload-city-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: #5a9970;
}

.upload-city-picker {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #027525;
  text-align: right;
  cursor: pointer;
  padding: 4px 0;
}

.upload-city-picker:hover {
  text-decoration: underline;
}

.city-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #7db894;
  margin-bottom: 6px;
}

.city-name {
  font-size: clamp(17px, 4.2vw, 22px);
  font-weight: 700;
  color: #f0faf3;
  overflow-wrap: anywhere;
}

@media (max-width: 400px) {
  .middle-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .recent-square {
    min-height: 140px;
  }
}

.card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #5a9970;
  margin-bottom: 6px;
}

.card-hint {
  font-size: 14px;
  color: #3d7a55;
  line-height: 1.4;
}

.recent-title {
  font-size: 14px;
  font-weight: 700;
  color: #027525;
  line-height: 1.35;
  margin-bottom: 4px;
}

.recent-hint {
  font-size: 11px;
  font-weight: 600;
  color: #6aaa82;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* City search modal */
.city-modal[hidden] {
  display: none !important;
}

.city-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px))
    max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  box-sizing: border-box;
}

.city-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 25, 0.45);
}

.city-modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 520px;
  max-height: min(640px, 85vh);
  background: #fff;
  border-radius: 18px;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  padding: 14px 16px 24px;
  /* flex child can shrink inside padded overlay */
  min-height: 0;
}

.city-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.city-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: #1e3d2e;
}

.city-modal-close {
  border: none;
  background: #e8eeea;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}

.city-modal-close:hover {
  background: #dde6e0;
}

.city-modal-search {
  width: 100%;
  border: 1px solid #bccac2;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  margin-bottom: 10px;
}

.city-modal-results {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  border: 1px solid #dde8e3;
  border-radius: 12px;
}

.city-modal-results li {
  border-bottom: 1px solid #eef4f1;
}

.city-modal-results li:last-child {
  border-bottom: none;
}

.city-modal-results button {
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: #fff;
  font: inherit;
  font-size: 14px;
  color: #1e3d2e;
  text-align: left;
  cursor: pointer;
}

.city-modal-results button:hover {
  background: #f3faf6;
}

/* Upload */
.upload-block {
  margin-top: 20px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #b8dfc4;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  width: 100%;
  text-align: left;
  appearance: none;
  font-family: inherit;
}

.upload-block:hover {
  background: #f8fcf9;
}

.upload-text-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bottom-panel {
  margin-top: 20px;
  flex: 1;
  min-height: 160px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #b8dfc4;
  padding: 18px 18px 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.episodes-panel {
  min-height: 200px;
}

.config-hint {
  font-size: 14px;
  color: #a33;
  margin: 8px 0 4px;
  line-height: 1.45;
}

.episodes-status {
  font-size: 14px;
  color: #5a9970;
  min-height: 1.2em;
  margin-bottom: 8px;
}

.episodes-real-list {
  flex: 1;
  margin-top: 8px;
  min-height: 0;
  overflow-y: auto;
  width: 100%;
}

.episode-play-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(10px, 1vw);
  border-radius: 10px;
  border: 1px solid #c5e6d2;
  background: #f5fcf8;
  margin-bottom: 8px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
  max-width: 100%;
  font: inherit;
  transition: opacity 0.12s ease;
}

.episode-play-row:not(:disabled):active {
  opacity: 0.85;
}

.episode-play-row.is-active {
  border-color: #9dd4b4;
  background: #edfaf1;
}

.episode-play-row:disabled {
  cursor: not-allowed;
  opacity: 0.78;
  border-color: #d5ebe0;
  background: #f5faf7;
}

.episode-play-row.is-failed:disabled {
  border-color: #e8c9c9;
  background: #fff8f8;
}

.episode-play-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  color: #027525;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.episode-play-action {
  font-size: 14px;
  font-weight: 700;
  color: #016020;
  flex-shrink: 0;
  min-width: 4rem;
  text-align: right;
}

.episode-play-row:disabled .episode-play-action {
  color: #6b8f76;
}

.episode-play-row.is-failed:disabled .episode-play-action {
  color: #a33;
}

.episode-loading {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid #b8dfc4;
  border-top-color: #027525;
  border-radius: 50%;
  animation: episode-spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* Player — same visual language as app playerBar */
.listen-player {
  margin-top: 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #b8dfc4;
  padding: 16px 16px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.listen-player-inner {
  max-width: none;
}

.listen-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.listen-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: #027525;
  line-height: 1.33;
  overflow-wrap: anywhere;
}

.listen-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: none;
  background: #d4f0e0;
  color: #016020;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.listen-close:hover {
  opacity: 0.92;
}

.listen-scrub-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  margin-top: -4px;
}

.listen-scrub-row input[type='range'] {
  flex: 1;
  height: 40px;
  accent-color: #027525;
  cursor: pointer;
}

.listen-time {
  font-size: 12px;
  font-weight: 600;
  color: #5a9970;
  font-variant-numeric: tabular-nums;
  min-width: 2.75rem;
}

.listen-time:last-child {
  text-align: right;
}

.listen-play-toggle {
  display: block;
  width: fit-content;
  min-width: 120px;
  margin: 0 auto;
  padding: 12px 40px;
  border: none;
  border-radius: 12px;
  background: #027525;
  color: #f0faf3;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.listen-play-toggle:hover {
  opacity: 0.95;
}

.listen-play-toggle:active {
  opacity: 0.92;
}
