:root {
  color-scheme: light;
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 20px;
  color: #18231f;
  background: #f5f1e8;
  --ink: #18231f;
  --green: #173f35;
  --green-soft: #e7f1ed;
  --orange: #b34a00;
  --line: #c9bda9;
}
* {
  box-sizing: border-box;
}
/* 화면 회전 중 넓어진 요소가 가로 스크롤·축소 배율을 만들지 않게 한다. */
html {
  overflow-x: hidden;
}
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
select,
input {
  min-height: 60px;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
input[type="checkbox"] {
  width: auto;
  min-height: 24px;
}
a {
  color: var(--green);
}
.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  color: #fff;
  background: var(--green);
  transform: translateY(-150%);
}
.skip-link:focus {
  transform: translateY(0);
}
.offline-banner {
  margin: 0;
  padding: 0.75rem 1rem;
  color: #fff;
  background: #7a2e00;
  text-align: center;
  font-weight: 800;
}
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 5vw, 3rem);
  border-bottom: 2px solid var(--line);
}
.brand {
  color: var(--green);
  font-size: 1.4rem;
  font-weight: 900;
  text-decoration: none;
}
.profile-name {
  margin: 0;
  font-weight: 800;
}
.shell {
  display: grid;
  width: min(100%, 52rem);
  min-height: calc(100vh - 4rem);
  margin: auto;
  padding: clamp(1rem, 5vw, 3rem) 1rem;
  gap: 1.5rem;
}
.search-card,
.quick-section,
.recent-section,
.player-panel,
.admin-card {
  min-width: 0;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  border: 2px solid var(--line);
  border-radius: 1.25rem;
  background: #fffdf8;
  box-shadow: 0 0.5rem 1.5rem rgb(23 63 53 / 10%);
}
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
  padding: 0.4rem;
  border: 2px solid var(--green);
  border-radius: 1.1rem;
  background: var(--green-soft);
}
.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-width: 0;
  min-height: 68px;
  padding: 0.6rem 0.5rem;
  border: 0;
  border-radius: 0.8rem;
  color: var(--green);
  background: transparent;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}
.mode-tab:hover:not(.is-active) {
  background: #d6e8e1;
}
.mode-tab:focus-visible {
  outline: 4px solid #ffd166;
  outline-offset: 2px;
}
.mode-tab.is-active {
  color: #fff;
  background: var(--green);
  box-shadow: 0 0.3rem 0.8rem rgb(23 63 53 / 25%);
}
.mode-icon {
  flex: none;
  font-size: 1.2rem;
  line-height: 1;
}
.mode-label {
  white-space: nowrap;
}
@media (max-width: 360px) {
  .mode-tab {
    font-size: 1rem;
  }
  .mode-icon {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mode-tab {
    transition: none;
  }
}
.eyebrow {
  margin: 0 0 0.5rem;
  color: #356a5c;
  font-weight: 800;
}
h1 {
  margin: 0 0 1.5rem;
  font-size: clamp(1.8rem, 8vw, 3rem);
  line-height: 1.15;
}
h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.4rem, 6vw, 2rem);
}
label {
  display: block;
  margin: 1.25rem 0 0.4rem;
  font-weight: 800;
}
textarea,
input,
select {
  width: 100%;
  padding: 0.75rem;
  border: 3px solid #6f756f;
  border-radius: 0.75rem;
  background: #fff;
  color: var(--ink);
}
textarea {
  min-height: 104px;
  resize: vertical;
  font-size: 1.1rem;
  line-height: 1.45;
}
.microphone {
  display: grid;
  width: 132px;
  min-height: 132px;
  margin: 1.25rem auto 0.75rem;
  border: 0;
  border-radius: 50%;
  place-content: center;
  gap: 0.25rem;
  color: #fff;
  background: var(--green);
  font-size: 1.05rem;
  font-weight: 900;
  box-shadow: 0 0.5rem 0 #0d2822;
}
.microphone span:first-child {
  font-size: 2.1rem;
}
.microphone.is-listening {
  background: #8b2500;
  box-shadow: 0 0.5rem 0 #551700;
}
.help {
  text-align: center;
}
.primary-button {
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 0.75rem;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}
.primary-button.needs-confirmation:not(:disabled) {
  animation: search-attention 0.75s ease-in-out infinite alternate;
  outline: 5px solid #ffd166;
  outline-offset: 3px;
}
.status {
  min-height: 3rem;
  margin: 1rem 0 0;
  padding: 0.85rem;
  border-left: 0.35rem solid #356a5c;
  background: var(--green-soft);
  font-weight: 700;
}
.status.is-error {
  border-color: #9a2f00;
  background: #fff0e8;
}
.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}
.quick-button {
  min-height: 88px;
  padding: 0.75rem;
  border: 2px solid var(--green);
  border-radius: 1rem;
  color: var(--green);
  background: #fff;
  font-weight: 900;
  overflow-wrap: anywhere;
}
.recent-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 100%;
  gap: 0.65rem;
  padding: 0.25rem 0;
}
.recent-chip {
  width: 100%;
  min-height: 72px;
  padding: 0.75rem;
  border: 2px solid #356a5c;
  border-radius: 999px;
  background: #fff;
  text-align: left;
  overflow-wrap: anywhere;
}
.player-panel {
  scroll-margin-top: 1rem;
}
.player-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.player-heading h2 {
  overflow-wrap: anywhere;
}
.icon-button {
  width: 60px;
  flex: 0 0 60px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  font-weight: 900;
}
.music-art {
  display: grid;
  width: 180px;
  height: 180px;
  margin: 1rem auto;
  border: 0.8rem solid #2a2a2a;
  border-radius: 50%;
  place-items: center;
  color: #fff;
  background: radial-gradient(
    circle,
    #c84f17 0 20%,
    #222 21% 55%,
    #454545 56% 60%,
    #222 61%
  );
  font-size: 3rem;
}
.music-art.is-spinning {
  animation: spin 5s linear infinite;
}
.youtube-frame {
  width: min(100%, 28rem);
  min-height: 158px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #111;
  aspect-ratio: 16 / 9;
}
.youtube-frame iframe,
#youtube-player {
  width: 100%;
  height: 100%;
  min-height: 158px;
  border: 0;
}
.player-panel[data-mode="video"] .music-art {
  display: none;
}
.player-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.8rem 0 1rem;
}
.player-controls button {
  padding: 0.5rem;
  border: 2px solid var(--green);
  border-radius: 0.75rem;
  background: #fff;
  font-weight: 800;
}
.youtube-frame:fullscreen,
.youtube-frame:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  margin: 0;
  padding: 0;
  border-radius: 0;
  aspect-ratio: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.youtube-frame:fullscreen iframe,
.youtube-frame:-webkit-full-screen iframe {
  width: 100%;
  height: 100%;
  border: 0;
}
.fullscreen-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 58px;
  margin: 0 0 0.75rem;
  padding: 0.75rem 1rem;
  border: 3px solid var(--green);
  border-radius: 0.75rem;
  background: var(--green-soft);
  color: var(--green);
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 0.25rem 0.5rem rgb(23 63 53 / 15%);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.fullscreen-button:hover {
  background: #d5e7df;
}
.player-panel[data-mode="music"] .fullscreen-button {
  display: none;
}
.similar-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 58px;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 3px solid #b26a00;
  border-radius: 0.75rem;
  background: #fff8e7;
  color: #78350f;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 0.25rem 0.5rem rgb(178 106 0 / 15%);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.similar-button:hover {
  background: #fdeec6;
}
.similar-button:active {
  transform: scale(0.98);
}
.related-videos-section {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px dashed var(--line);
}
.related-videos-title {
  margin: 0 0 0.85rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.related-videos-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.related-video-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  width: 100%;
  min-height: 64px;
  padding: 0.9rem 1.1rem;
  border: 2px solid #cbd5e1;
  border-radius: 0.85rem;
  background: #ffffff;
  color: #1e293b;
  text-align: left;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}
.related-video-item:hover {
  background: #f8fafc;
  border-color: var(--green);
  transform: translateY(-1px);
}
.related-video-item:active {
  transform: scale(0.99);
}
.related-video-item.is-active {
  border: 3px solid var(--green);
  background: #f0fdf4;
  color: #14532d;
  font-weight: 900;
  box-shadow: 0 3px 8px rgba(23, 63, 53, 0.15);
}
.related-video-item .video-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.5rem;
  background: #e2e8f0;
  color: #334155;
  font-size: 1rem;
  font-weight: 800;
  flex-shrink: 0;
}
.related-video-item.is-active .video-badge {
  background: var(--green);
  color: #ffffff;
}
/* 제목이 길어도 두 줄까지만 보이고 나머지는 "…"로 줄여 목록 한 칸이 커지지 않게 한다. */
.related-video-item .video-title-text {
  display: -webkit-box;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}
.app-footer {
  padding: 1.5rem;
  border-top: 2px solid var(--line);
  text-align: center;
  font-size: 0.9rem;
}
.app-footer p {
  margin: 0 0 0.4rem;
}
.field-error {
  color: #8b2500;
  font-weight: 700;
}
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}
.form-actions button {
  flex: 1 1 10rem;
}
.preferences-editor {
  margin: 1rem 0;
  padding: 1.25rem;
  border: 2px solid var(--green);
  border-radius: 0.75rem;
  background: #fbf9f4;
}
.preferences-editor legend {
  font-weight: 900;
  color: var(--green);
}
.button-editor {
  margin: 1rem 0;
  padding: 1rem;
  border: 2px solid var(--line);
  border-radius: 0.75rem;
}
.button-editor legend {
  font-weight: 900;
}
.help-text {
  line-height: 1.6;
}
.quota-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(12rem, 18rem);
  gap: 1rem;
  align-items: center;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--green-soft);
}
.quota-summary h3,
.quota-summary p {
  margin: 0.25rem 0;
}
.quota-summary progress {
  width: 100%;
  height: 1.4rem;
  accent-color: var(--green);
}
.table-scroll {
  max-width: 100%;
  margin-bottom: 1.5rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}
table {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.85rem;
}
th,
td {
  padding: 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--green-soft);
  white-space: nowrap;
}
[hidden] {
  display: none !important;
}

/* ========================================================
   Admin Dashboard & Modern Management Styles
   ======================================================== */
.admin-shell {
  width: min(100%, 62rem);
  gap: 1.75rem;
}
.header-brand-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.admin-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid var(--green);
  border-radius: 9999px;
}
.admin-user-tag {
  font-size: 0.85rem;
  font-weight: 700;
  color: #4a5568;
}
.outline-button {
  padding: 0.5rem 1rem;
  font-weight: 700;
  color: var(--green);
  background: transparent;
  border: 2px solid var(--green);
  border-radius: 0.6rem;
  transition: all 0.15s ease;
}
.outline-button:hover {
  color: #fff;
  background: var(--green);
}
.outline-button.sm {
  min-height: 42px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

/* Tabs */
.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.35rem;
  background: #e9e3d5;
  border-radius: 0.9rem;
}
.admin-tab {
  flex: 1 1 auto;
  min-height: 48px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: #4a5568;
  background: transparent;
  border: none;
  border-radius: 0.65rem;
  transition: all 0.2s ease;
}
.admin-tab:hover {
  color: var(--ink);
  background: rgb(255 255 255 / 40%);
}
.admin-tab.is-active {
  color: var(--green);
  background: #fff;
  box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.15rem 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 2px 6px rgb(0 0 0 / 4%);
}
.kpi-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  font-size: 1.6rem;
  background: var(--green-soft);
  border-radius: 0.8rem;
  flex-shrink: 0;
}
.kpi-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.kpi-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: #6b7280;
}
.kpi-value {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
}
.kpi-sub {
  font-size: 0.75rem;
  color: #107048;
  font-weight: 600;
}

/* User Filter Chips */
.filter-section {
  margin: 1.25rem 0;
  padding: 1rem;
  background: #fdfbf7;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}
.filter-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}
.filter-title {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--green);
}
.filter-hint {
  font-size: 0.8rem;
  color: #6b7280;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip-btn {
  min-height: 42px;
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 9999px;
  transition: all 0.15s ease;
}
.chip-btn:hover {
  border-color: var(--green);
  background: var(--green-soft);
}
.chip-btn.is-active {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 2px 6px rgb(23 63 53 / 30%);
}

/* Dashboard Section & Cards */
.dashboard-section {
  scroll-margin-top: 1.5rem;
}
.section-header {
  border-bottom: 2px solid var(--line);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}
.form-card {
  margin: 1rem 0;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
}
.form-card.highlight-card {
  background: #fbfbf7;
  border: 2px solid var(--green);
}
.form-card-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--green);
}
.form-card-desc {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #555;
  line-height: 1.5;
}
.form-row-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.form-field {
  margin-bottom: 0.75rem;
}
.form-check-row {
  margin-top: 0.5rem;
}
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
}
.button-grid-editors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}
.form-footer {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}
.save-btn {
  min-width: 10rem;
}

/* Tables & Data Cards */
.data-card {
  margin: 1.5rem 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  overflow: hidden;
}
.data-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  background: #fcfbfa;
  border-bottom: 1px solid var(--line);
}
.data-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}
.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 9999px;
  background: var(--green-soft);
  color: var(--green);
}
.modern-table {
  width: 100%;
  margin: 0;
  border: none;
  font-size: 0.85rem;
}
.modern-table tbody tr:hover {
  background: #fbf9f4;
}

/* Quota Hero Card */
.quota-hero-card {
  margin: 1rem 0 1.5rem;
  padding: 1.5rem;
  background: var(--green-soft);
  border: 2px solid var(--green);
  border-radius: 1rem;
}
.quota-summary-text {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--green);
  margin: 0 0 0.5rem;
}
.quota-progress-bar {
  width: 100%;
  height: 1.5rem;
  accent-color: var(--green);
  border-radius: 9999px;
  overflow: hidden;
}

/* Status & Actions */
.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}
.login-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.login-btn {
  width: 100%;
}
.access-denied-box {
  margin-top: 1rem;
  padding: 1rem;
  background: #fee2e2;
  border: 1px solid #ef4444;
  border-radius: 0.75rem;
  color: #991b1b;
  font-weight: 700;
}
:focus-visible {
  outline: 4px solid var(--orange);
  outline-offset: 4px;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes search-attention {
  from {
    background: var(--green);
    box-shadow: 0 0 0 0 rgb(179 74 0 / 20%);
  }
  to {
    background: var(--orange);
    box-shadow: 0 0 0 0.45rem rgb(179 74 0 / 22%);
  }
}

/* User Selection & Actions */
.user-select-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.user-select-row .field-grow {
  flex: 1 1 auto;
}
.add-user-btn {
  white-space: nowrap;
  height: 52px;
  align-self: flex-end;
  border-width: 2px;
  font-weight: 800;
}
.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
}
.config-actions button {
  flex: 1 1 12rem;
}
.danger-button {
  padding: 0.8rem 1rem;
  border: 2px solid #ef4444;
  border-radius: 0.75rem;
  color: #dc2626;
  background: #fff;
  font-size: 1rem;
  font-weight: 800;
  transition: all 0.15s ease;
  cursor: pointer;
}
.danger-button:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #dc2626;
}

/* Modern Dialog */
.modern-dialog {
  border: none;
  border-radius: 1.25rem;
  padding: 1.75rem;
  box-shadow: 0 1.25rem 3rem rgb(0 0 0 / 25%);
  width: min(90vw, 28rem);
  background: #fffdf8;
}
.modern-dialog::backdrop {
  background: rgb(0 0 0 / 50%);
  backdrop-filter: blur(4px);
}
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.dialog-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--green);
}
.dialog-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #666;
  padding: 0.25rem;
}
.dialog-desc {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}
.dialog-fields {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}
.add-submit-btn {
  width: auto;
  margin-top: 0;
}

@media (max-width: 640px) {
  .admin-shell {
    padding: 1rem 0.5rem;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .form-row-2 {
    grid-template-columns: 1fr;
  }
  .button-grid-editors {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 420px) {
  .quota-summary {
    grid-template-columns: 1fr;
  }
  .quick-grid,
  .recent-list {
    grid-template-columns: 1fr;
  }
  .player-controls {
    grid-template-columns: 1fr;
  }
}
@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;
  }
  /* 휴대폰의 "애니메이션 줄이기/제거" 설정이 켜져 있어도 찾기 버튼 안내는 유지한다.
     움직임 없이 색과 테두리 빛만 천천히 바뀌므로 어지럼을 주지 않는다. */
  .primary-button.needs-confirmation:not(:disabled) {
    background: var(--orange);
    animation-duration: 1.1s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ── 검색 카드 한 화면 배치 ──────────────────────────────
   휴대폰 한 화면(브라우저 주소창 포함 약 700px) 안에 모드 선택부터
   "이 내용으로 찾기" 버튼과 안내 문구까지 모두 보이도록 세로 간격을 줄인다. */
.search-card .eyebrow {
  margin-bottom: 0.2rem;
  font-size: 0.95rem;
}
.search-card h1 {
  margin-bottom: 0.9rem;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
}
.voice-row {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.voice-row .microphone {
  flex: none;
  width: 112px;
  min-height: 112px;
  margin: 0 0 0.5rem;
}
.voice-row .help {
  margin: 0;
  word-break: keep-all;
  text-align: left;
  font-weight: 700;
  line-height: 1.4;
}
.search-card label {
  margin: 0.9rem 0 0.35rem;
}
.search-card textarea {
  min-height: 84px;
}
.search-card .primary-button {
  min-height: 64px;
  margin-top: 0.75rem;
}
.search-card .status {
  min-height: 0;
  word-break: keep-all;
  margin-top: 0.75rem;
  padding: 0.7rem 0.85rem;
  line-height: 1.4;
  scroll-margin-bottom: 1rem;
}
@media (max-width: 640px) {
  .app-header {
    padding: 0.6rem 1rem;
  }
  .shell {
    padding-top: 0.75rem;
    gap: 1rem;
  }
  .search-card {
    padding: 1rem;
  }
  .mode-selector {
    margin-bottom: 0.9rem;
  }
  .mode-tab {
    min-height: 60px;
  }
  /* 모드 탭이 이미 음악/영상을 알려 주므로 작은 화면에서는 보조 제목을 숨긴다. */
  .search-card .eyebrow {
    display: none;
  }
  .search-card h1 {
    font-size: clamp(1.45rem, 6.6vw, 2rem);
    margin-bottom: 0.75rem;
  }
  /* 입력칸 라벨은 화면 읽기 프로그램에만 전달하고 공간을 아낀다. */
  .search-card label[for="search-text"] {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .voice-row {
    margin-bottom: 0.75rem;
  }
  .voice-row .microphone {
    width: 104px;
    min-height: 104px;
  }
  .search-card textarea {
    min-height: 76px;
  }
}
@media (max-width: 340px) {
  .voice-row {
    flex-direction: column;
  }
  .voice-row .help {
    text-align: center;
  }
}

/* 빠른 버튼(.quick-button)과 같은 모양을 쓰고, 한 줄 전체 너비만 차지한다. */
.recommend-button {
  display: block;
  width: 100%;
  margin-bottom: 0.9rem;
  word-break: keep-all;
}

/* ── 그리드 넘침 방지 ─────────────────────────────────────
   넓은 표가 화면 전체 폭을 늘리지 않도록 한 칸 그리드의 최소 폭을 0으로 둔다. */
.shell {
  grid-template-columns: minmax(0, 1fr);
}
.shell > * {
  min-width: 0;
}

/* ── 관리자 화면: 휴대폰 배치 ─────────────────────────────── */
@media (max-width: 640px) {
  .admin-header {
    padding: 0.6rem 0.75rem;
  }
  .admin-badge,
  .admin-user-tag {
    white-space: nowrap;
  }
  .admin-shell {
    gap: 1rem;
    padding-top: 0.75rem;
  }
  .admin-body .admin-card {
    padding: 1rem 0.85rem;
  }
  .admin-body .form-card,
  .admin-body .button-editor,
  .admin-body .preferences-editor,
  .admin-body .filter-section {
    padding: 0.75rem;
  }
  .admin-body .section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .admin-body h1 {
    font-size: 1.6rem;
  }
  .admin-body h2 {
    font-size: 1.35rem;
    word-break: keep-all;
  }

  /* 탭 3개를 한 줄에 */
  .admin-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
  }
  .admin-tab {
    min-height: 56px;
    padding: 0.45rem 0.3rem;
    font-size: 0.8rem;
    line-height: 1.25;
    word-break: keep-all;
  }

  /* 요약 지표 2열 */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
  }
  .kpi-card {
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.8rem;
  }
  .kpi-icon {
    display: none;
  }
  .kpi-label,
  .kpi-sub {
    word-break: keep-all;
  }
  .kpi-value {
    font-size: 1.15rem;
  }

  /* 사용자 선택 + 새 가족 추가 버튼을 위아래로 */
  .user-select-row {
    flex-wrap: wrap;
  }
  .user-select-row .field-grow,
  .add-user-btn {
    flex: 1 1 100%;
    width: 100%;
  }
  .form-footer,
  .config-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .save-btn,
  .config-actions button,
  .form-footer > * {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  /* 표를 카드 목록으로 */
  .admin-body .table-scroll {
    overflow: visible;
    border: 0;
  }
  .admin-body table {
    min-width: 0;
    background: transparent;
  }
  .admin-body thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .admin-body tbody tr {
    display: block;
    margin: 0.6rem 0.6rem 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
  }
  .admin-body tbody tr:last-child {
    margin-bottom: 0.6rem;
  }
  .admin-body tbody td {
    display: grid;
    grid-template-columns: 6.5rem minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.35rem 0;
    border-bottom: 1px dashed #e5ddcc;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
  }
  .admin-body tbody td:last-child {
    border-bottom: 0;
  }
  .admin-body tbody td::before {
    content: attr(data-label);
    color: #6b7280;
    font-weight: 800;
    font-size: 0.8rem;
  }
  .admin-body tbody td.is-empty-cell {
    display: block;
  }
  .admin-body tbody td.is-empty-cell::before {
    content: none;
  }
}

/* 상단 제목 "유튜브 찾기": 좁은 화면에서도 한 줄 또는 단어 단위로 줄바꿈 */
.app-header .brand {
  min-width: 0;
  word-break: keep-all;
  line-height: 1.2;
}
.profile-name {
  flex: none;
}
@media (max-width: 420px) {
  .app-header .brand {
    font-size: 1.2rem;
  }
}

/* 화면 꺼짐 방지 상태 안내 */
.wake-status {
  margin: 0.75rem 0 0;
  padding: 0.55rem 0.8rem;
  border-radius: 0.6rem;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.4;
  word-break: keep-all;
}
.wake-status.is-warning {
  color: #7a2e00;
  background: #fff0e8;
}

/* ── 상단 고정 메뉴 줄 ────────────────────────────────────
   화면을 내려도 삼선(메뉴) 버튼과 제목 줄이 늘 위에 남아 있게 한다. */
#app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  justify-content: flex-start;
  background: #f5f1e8;
  box-shadow: 0 0.25rem 0.75rem rgb(23 63 53 / 10%);
}
#app-header .brand {
  flex: 1;
}
.menu-toggle {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.45rem;
  min-height: 60px;
  padding: 0.4rem 0.8rem;
  border: 2px solid var(--green);
  border-radius: 0.8rem;
  color: var(--green);
  background: #fff;
  font-weight: 900;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.menu-toggle[aria-expanded="true"] {
  color: #fff;
  background: var(--green);
}
.menu-icon {
  display: grid;
  gap: 5px;
  width: 26px;
}
.menu-icon span {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
}
.section-menu {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0.85rem 1rem 1rem;
  border-bottom: 2px solid var(--line);
  background: #fffdf8;
  box-shadow: 0 0.75rem 1.5rem rgb(23 63 53 / 18%);
}
.section-menu[hidden] {
  display: none;
}
.section-menu button {
  min-height: 68px;
  padding: 0.5rem;
  border: 2px solid var(--green);
  border-radius: 0.85rem;
  color: var(--green);
  background: var(--green-soft);
  font-size: 1.1rem;
  font-weight: 900;
  word-break: keep-all;
}
.section-menu button[hidden] {
  display: none;
}

/* 메뉴로 이동할 때 고정된 제목 줄에 구간 제목이 가려지지 않게 한다. */
.shell > section,
.search-card .status {
  scroll-margin-top: calc(var(--header-height, 5rem) + 0.75rem);
}
.shell > section:focus {
  outline: none;
}
.shell > section:focus-visible {
  outline: 4px solid #ffd166;
  outline-offset: 2px;
}

/* ── 구간 오른쪽 위 "맨 위로" 버튼 ──────────────────────── */
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.section-heading h2 {
  margin: 0;
  min-width: 0;
}
.to-top-button {
  flex: none;
  min-height: 60px;
  padding: 0.4rem 0.75rem;
  border: 2px solid var(--line);
  border-radius: 0.8rem;
  color: var(--ink);
  background: #fff;
  font-size: 1rem;
  font-weight: 800;
  white-space: nowrap;
}
.player-heading .to-top-button {
  margin-left: auto;
}
@media (max-width: 420px) {
  #app-header {
    gap: 0.6rem;
  }
  .menu-toggle {
    padding: 0.4rem 0.6rem;
  }
}
@media (max-width: 360px) {
  .menu-toggle-label {
    display: none;
  }
}
/* 재생 화면: "맨 위로"·닫기 버튼은 윗줄 오른쪽에, 제목은 아랫줄 전체 폭을 쓴다. */
.player-heading {
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}
.player-heading > div {
  flex: 1 1 100%;
  order: 2;
  min-width: 0;
}
