:root {
    --bg: #fbfcfb;
    --card: #ffffff;
    --text: #17211f;
    --muted: #63706d;
    --line: #dfe7e4;
    --green: #087467;
    --green-dark: #075c53;
    --green-pale: #edf6f3;
    --turquoise: #087467;
    --turquoise-dark: #075c53;
    --turquoise-soft: #edf6f3;
    --orange: #087467;
    --orange-dark: #075c53;
    --orange-soft: #edf6f3;
    --danger: #c94c4c;
    --warning: #e8a317;
    --success: #087467;
    --shadow: 0 14px 40px rgba(16, 59, 54, .08);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 14px;
    --tap: 48px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
    background:
      radial-gradient(circle at 88% 8%, rgba(8, 116, 103, .05), transparent 25rem),
      radial-gradient(circle at 8% 34%, rgba(8, 116, 103, .03), transparent 22rem),
      var(--bg);
    color: var(--text);
    font-size: 16px;
}
a { color: var(--orange-dark); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(8, 116, 103, .28);
    outline-offset: 2px;
}

.topbar {
    min-height: 68px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 clamp(16px, 5vw, 24px);
    padding-top: env(safe-area-inset-top);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__left, .topbar__right { display: flex; align-items: center; gap: 8px; }
.brand {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap);
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
}
.brand--logo {
    padding: 4px 0;
}
.brand-logo-img {
    display: block;
    height: 34px;
    width: auto;
    max-width: 132px;
    object-fit: contain;
}

.container {
    width: min(680px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 32px;
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
}
.container--wide { width: min(900px, calc(100% - 32px)); }
.container--home { width: min(1280px, calc(100% - 32px)); }
.container--admin { width: min(1280px, calc(100% - 32px)); }

.icon-button--danger {
  background: #fff4e8;
  color: #e8751a;
}
.icon-button--danger:hover {
  background: #edf6f3;
  color: #087467;
}

.badge--muted {
  background: #eef1f0 !important;
  color: #5a6a64 !important;
}

.cad-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}
.cad-toolbar label {
  display: block;
  font-size: .78rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 4px;
}
.cad-toolbar input,
.cad-toolbar select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  font: inherit;
  background: #fbfeff;
  min-width: 160px;
}
.cad-cards {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .cad-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .cad-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .cad-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.cad-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: var(--shadow);
  min-height: 0;
}
.cad-card__name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.2;
}
.cad-card__user {
  margin: 0;
  font-size: .82rem;
  color: var(--muted);
}
.cad-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.cad-card__actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}
.cad-card__actions .button { flex: 1; }

.cfg-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 860px) {
  .cfg-grid { grid-template-columns: 1fr 1fr; }
}
.cfg-grid .card { margin-bottom: 0; }
.cfg-status {
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  min-height: 1.2em;
}

.story-list-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .story-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .story-list-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .story-list-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.story-list-grid .deck-pick {
  margin: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 88px;
}
.story-list-grid .deck-pick__arrow { align-self: flex-end; }

.atr-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 16px;
  border-bottom: 2px solid var(--line);
}
.atr-tabs button {
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
}
.atr-tabs button.is-active {
  color: #087467;
  border-bottom-color: #087467;
}
.atr-form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
@media (min-width: 860px) {
  .atr-form-grid { grid-template-columns: 1fr 1fr; }
}
.atr-form-grid .atr-span-2 { grid-column: 1 / -1; }

.hx-fab-home {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 9999;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #ffe8d6;
  color: #c45c12;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
  text-decoration: none;
}
.hx-fab-home:hover { background: #ffd9bc; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: clamp(18px, 4vw, 24px);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.card--flat { box-shadow: none; }

h1, h2, h3 { margin: 0 0 8px; letter-spacing: -.03em; line-height: 1.15; }
h1 { font-size: clamp(1.6rem, 6vw, 2rem); }
h2 { font-size: clamp(1.2rem, 4.5vw, 1.45rem); }
h3 { font-size: 1.05rem; }
p, .meta { color: var(--muted); line-height: 1.55; margin: 6px 0 0; }
.meta { font-size: .9rem; }

.hero {
    text-align: center;
    padding: 8px 0 20px;
}
.hero p { max-width: 36ch; margin-inline: auto; }

.feature-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}
.feature-grid .feature-card {
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  min-height: 0;
  padding: 16px;
  gap: 10px;
}
.feature-grid .feature-card__arrow { display: none; }
.feature-grid .feature-card__subtitle {
  display: block;
}
@media (min-width: 520px) {
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
@media (min-width: 780px) {
  .feature-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .feature-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* list layout: one full-width card per row */
.feature-grid.feature-grid--list {
  grid-template-columns: 1fr;
}
.feature-grid.feature-grid--list .feature-card {
  flex-direction: row;
  align-items: center;
  padding: 18px;
  gap: 16px;
}
.feature-grid.feature-grid--list .feature-card__arrow { display: inline-flex; }
.feature-grid.feature-grid--list .feature-card__subtitle {
  display: block;
}
.feature-grid--cols {
  /* kept for backwards compatibility with settings */
}
.feature-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    box-shadow: var(--shadow);
    transition: transform .15s ease, border-color .15s ease;
    min-height: 88px;
}
.feature-card:hover { transform: translateY(-2px); border-color: #c9d9d5; }
.feature-card__icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--green-pale);
    color: var(--green-dark);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.feature-card__body { flex: 1; min-width: 0; }
.feature-card__title {
    font-family: "DM Sans", system-ui, -apple-system, sans-serif;
    font-weight: 750;
    font-size: 1.08rem;
    line-height: 1.25;
    letter-spacing: 0;
    margin: 0 0 4px;
    color: var(--text);
}
.feature-card__subtitle {
    margin: 0;
    font-size: .82rem;
    font-weight: 550;
    line-height: 1.35;
    color: var(--muted);
}
.feature-card__arrow { color: var(--green); flex-shrink: 0; }

button, .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    background: var(--orange);
    color: #fff;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    transition: .15s ease;
}
button:hover, .button:hover { background: var(--orange-dark); transform: translateY(-1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.secondary { background: var(--orange-soft); color: var(--orange-dark); }
.button.secondary:hover { background: #ffe8d6; }
.button.danger { background: var(--danger); }
.button.ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--line);
}
.button.ghost:hover { background: #fff; color: var(--text); }
.button.icon-only {
    width: var(--tap);
    min-width: var(--tap);
    padding: 0;
    border-radius: 50%;
}
.button.icon-only.active { background: #fdeeee; color: var(--danger); }
.button.sm { min-height: 40px; padding: 8px 12px; font-size: .88rem; }
.full { width: 100%; }

.icon-button {
    width: var(--tap);
    height: var(--tap);
    border: none;
    border-radius: 50%;
    background: var(--orange-soft);
    color: var(--orange-dark);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    transition: .15s ease;
    flex-shrink: 0;
}
.icon-button:hover { background: #ffe8d6; }

.deck-list { display: grid; gap: 10px; }
#deck-root { display: contents; }

.deck-pick {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 16px 18px;
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, border-color .15s ease;
  margin-bottom: 0;
}
.deck-pick:hover { transform: translateY(-2px); border-color: #c9d9d5; }
.deck-pick__title {
  flex: 1;
  font-weight: 850;
  font-size: 1.05rem;
}
.deck-pick__arrow { color: var(--orange); flex-shrink: 0; }
.deck-pick--fav {
  background: #fff5f5;
  border-color: #ffd0d0;
}
.deck-pick--fav .deck-pick__title { color: var(--danger); }

.deck-section-title {
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--orange-dark);
    margin: 18px 0 8px;
    font-weight: 850;
}
.deck-section-title:first-child { margin-top: 0; }

.deck-card { margin-bottom: 0; }
.deck-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.deck-card__title { margin: 0; font-size: 1.1rem; }
.deck-card__actions { display: grid; gap: 8px; }

.deck-link--fav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: #fff5f5;
    border: 1px solid #ffd0d0;
    color: var(--danger);
    font-weight: 800;
    margin-bottom: 10px;
}
.deck-link--fav__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

.import-export { display: grid; gap: 10px; margin-top: 8px; }
.file-input { position: relative; overflow: hidden; }
.file-input input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.file-input .button { width: 100%; pointer-events: none; }

.study-page {
    display: flex;
    flex-direction: column;
    min-height: calc(100dvh - 68px);
}
.study-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.study-toolbar__actions { display: flex; flex-wrap: wrap; gap: 6px; }
.study-counter {
    font-weight: 850;
    color: var(--orange-dark);
    font-size: .9rem;
}
.flashcard {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 280px;
    padding: 24px 16px;
    margin-bottom: 16px;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
    cursor: pointer;
    gap: 12px;
}
.flashcard__front,
.flashcard__back {
    margin: 0;
    width: 100%;
}
.flashcard__face--hanzi {
    font-size: clamp(3.4rem, 16vw, 6.5rem);
    line-height: 1.1;
    font-weight: 500;
}
.flashcard__face--pinyin,
.flashcard__face--pt {
    font-size: clamp(1.25rem, 5vw, 1.75rem);
    color: var(--orange-dark);
    font-weight: 700;
    line-height: 1.35;
}
.flashcard__face--combo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.flashcard__hanzi-line {
    font-size: clamp(3rem, 14vw, 5.5rem);
    line-height: 1.1;
    font-weight: 500;
}
.flashcard__pinyin-line {
    font-size: clamp(1.1rem, 4.5vw, 1.5rem);
    color: var(--orange-dark);
    font-weight: 700;
}
.flashcard__back.is-hidden {
    color: transparent;
    user-select: none;
}
.flashcard__hanzi {
    font-size: clamp(4rem, 18vw, 7rem);
    line-height: 1.1;
    margin: 0 0 16px;
    font-weight: 500;
}
.flashcard__pinyin {
    font-size: clamp(1.2rem, 5vw, 1.6rem);
    color: var(--orange-dark);
    font-weight: 700;
    min-height: 2rem;
    margin: 0;
}
.flashcard__pinyin.is-hidden { color: transparent; user-select: none; }
.flash-mode-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0 18px;
}
.flash-mode-field .perm-check {
    align-items: flex-start;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.study-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.study-controls__center {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-shrink: 0;
}
.study-controls .button.icon-only { background: var(--turquoise-soft); color: var(--turquoise-dark); }
.study-controls .button.icon-only:hover { background: #d8f2f4; }
.study-controls .button.icon-only.is-playing { background: var(--orange-soft); color: var(--orange-dark); }

.pinyin-section { margin-bottom: 8px; }
.pinyin-section__title {
    margin: 22px 0 12px;
    font-size: .92rem;
    font-weight: 850;
    letter-spacing: .1em;
    color: var(--orange-dark);
    text-transform: uppercase;
}
.pinyin-section:first-child .pinyin-section__title {
    margin-top: 4px;
}
.pinyin-block { padding: 16px; margin-bottom: 12px; }
.pinyin-block__title {
    margin: 0 0 12px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text);
}

.syllable-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 8px;
}
.syllable-btn {
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--card);
    color: var(--text);
    font-weight: 800;
    font-size: .95rem;
    cursor: pointer;
    transition: .12s ease;
}
.syllable-btn:hover, .syllable-btn.is-active {
    border-color: var(--orange);
    background: var(--orange-soft);
    color: var(--orange);
}
.syllable-btn.is-disabled {
    opacity: .35;
    cursor: not-allowed;
}

.tone-sheet, .modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(15, 55, 70, .35);
    display: none;
    align-items: flex-end;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
.tone-sheet.is-open, .modal.is-open { display: flex; }
.tone-sheet__panel, .modal__panel {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    max-height: 85dvh;
    overflow-y: auto;
}
.tone-sheet__title, .modal__title {
    font-weight: 850;
    font-size: 1.15rem;
    margin: 0 0 4px;
    color: var(--text);
}
.tone-sheet__subtitle, .modal__meta { color: var(--muted); font-size: .88rem; margin: 0 0 14px; }
.tone-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
.tone-btn {
    min-height: 56px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--orange-soft);
    color: var(--orange);
    font-weight: 850;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}
.tone-btn:hover { background: var(--orange); color: #fff; }
.tone-btn__label { font-size: .85rem; opacity: .85; }
.tone-btn__syllable { font-size: 1.15rem; }
.tone-sheet__close, .modal__close { width: 100%; margin-top: 12px; }

/* Modal X — quadrado; X verde; hover: fundo verde / X branco */
.hx-cfg-close,
.hx-modal__close,
.hx-chat-shell__close,
.hx-atr-close,
.modal-header .icon-btn,
button.icon-btn[aria-label="Fechar"],
.pa-diary-modal .icon-button[aria-label="Fechar"] {
  width: 2.1rem;
  height: 2.1rem;
  min-width: 2.1rem;
  min-height: 2.1rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d5e3da;
  border-radius: .55rem;
  background: #fff;
  color: #087467;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  transform: none;
}
.hx-cfg-close:hover,
.hx-modal__close:hover,
.hx-chat-shell__close:hover,
.hx-atr-close:hover,
.modal-header .icon-btn:hover,
button.icon-btn[aria-label="Fechar"]:hover,
.pa-diary-modal .icon-button[aria-label="Fechar"]:hover {
  background: #087467;
  color: #fff;
  border-color: #087467;
  transform: none;
  box-shadow: none;
}

.modal__body { color: var(--text); line-height: 1.6; }
.modal__body ul { margin: 8px 0; padding-left: 20px; }
.modal__body li { margin-bottom: 6px; }

.interval-form { display: grid; gap: 12px; margin: 14px 0; }
.interval-form > label:not(.perm-check),
.interval-form > div > label { display: block; font-weight: 800; margin-bottom: 6px; font-size: .9rem; }
.interval-form input:not([type="checkbox"]):not([type="radio"]),
.interval-form select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: #fbfeff;
    color: var(--text);
    box-sizing: border-box;
}
.interval-form select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%215a6e60' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.interval-form input:not([type="checkbox"]):not([type="radio"]):focus,
.interval-form select:focus {
    border-color: var(--orange);
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 116, 103, .14);
}
.interval-form textarea {
    width: 100%;
    min-height: 120px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    background: #fbfeff;
    resize: vertical;
}

.badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--orange-soft);
    color: var(--orange-dark);
    font-size: .75rem;
    font-weight: 850;
}

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--muted);
}

.brand-logo-link {
    display: inline-flex;
    align-items: center;
    border-radius: 12px;
    line-height: 0;
}
.brand-logo {
    border-radius: 10px;
    object-fit: cover;
}

#btn-novo[hidden],
#btn-sair[hidden],
#btn-listas[hidden] {
    display: none !important;
}

#header-brand {
    cursor: default;
    user-select: none;
    -webkit-user-select: none;
}

.material-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .material-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .material-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .material-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.material-card { margin-bottom: 0; }
.material-card__head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 10px;
}
.material-card__id {
    font-weight: 850;
    color: var(--orange-dark);
    font-size: .9rem;
    flex-shrink: 0;
}
.material-card__title {
    margin: 0;
    font-size: 1.05rem;
    flex: 1;
    word-break: break-word;
}
.material-card__body { margin-bottom: 4px; }
.material-card__link {
    color: var(--orange-dark);
    font-weight: 700;
    font-size: .9rem;
    word-break: break-all;
    display: inline-block;
}
.material-card__link:hover { text-decoration: underline; }
.material-card__delete {
    margin-top: 10px;
    color: var(--danger);
    border-color: #ffd0d0;
}

.material-type-field {
    border: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.material-type-field legend {
    font-weight: 800;
    font-size: .85rem;
    padding: 0;
    margin: 0;
    float: none;
}
.material-type-options {
    display: flex;
    gap: 6px;
}
.material-type-option {
    display: inline-flex;
    align-items: center;
    margin: 0;
    cursor: pointer;
}
.material-type-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.material-type-option span {
    display: inline-block;
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--muted);
    transition: .12s ease;
}
.material-type-option input:checked + span {
    background: var(--orange-soft);
    border-color: var(--orange);
    color: var(--orange-dark);
}

.material-type-option input:checked + span {
    background: var(--orange-soft);
    border-color: var(--orange);
    color: var(--orange-dark);
}

.perm-field {
    border: none;
    padding: 0;
    margin: 4px 0 0;
    display: grid;
    gap: 6px;
}
.perm-field legend {
    font-weight: 800;
    font-size: .85rem;
    padding: 0;
    margin-bottom: 2px;
}
.perm-sub {
    display: grid;
    gap: 4px;
    padding-left: 6px;
}
.perm-check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 500;
    line-height: 1.3;
    margin: 0;
    cursor: pointer;
}
.perm-check--sub {
    font-size: .82rem;
    color: var(--muted);
}
.perm-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    min-width: 15px;
    min-height: 15px;
    margin: 0;
    padding: 0;
    flex-shrink: 0;
    accent-color: var(--orange);
}

.material-text-content {
    white-space: pre-wrap;
    line-height: 1.55;
    font-size: .95rem;
    color: var(--ink);
}
.material-inline-image {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin: 10px 0 6px;
    border: 1px solid var(--line);
}
.material-audio {
    margin: 6px 0 2px;
}
.material-audio audio {
    width: 100%;
    display: block;
    height: 40px;
}
.material-download-link {
    display: inline-block;
    font-size: .78rem;
    color: var(--muted);
    text-decoration: underline;
    margin-top: 4px;
}

.view-as-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: min(52vw, 200px);
}
.view-as-label {
    font-size: .72rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
}
.view-as-select {
    min-height: 34px;
    max-width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font: inherit;
    font-size: .78rem;
    background: transparent;
    color: var(--text);
}

.audience-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 50vh;
    overflow-y: auto;
    margin: 12px 0;
}

.material-textarea {
    width: 100%;
    min-height: 160px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    font: inherit;
    font-size: .95rem;
    line-height: 1.55;
    background: #fbfeff;
    resize: vertical;
    box-sizing: border-box;
}
.material-textarea:focus {
    border-color: var(--orange);
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 116, 103, .14);
}

.audience-tabs {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 10px;
}
.audience-tabs__btn {
    min-height: 34px;
    padding: 4px 14px;
    border: none;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
}
.audience-tabs__btn.is-active {
    background: var(--orange-soft);
    color: var(--orange-dark);
}
.audience-panel[hidden] {
    display: none !important;
}

.app-menu,
.admin-menu {
    position: relative;
}
.app-menu__panel,
.admin-menu__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 150px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.app-menu__panel[hidden],
.admin-menu__panel[hidden] {
    display: none !important;
}
.app-menu__link,
.admin-menu__link {
    display: block;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
}
.app-menu__link:hover,
.admin-menu__link:hover {
    background: var(--orange-soft);
    color: var(--orange-dark);
}
.app-menu__action {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font: inherit;
    font-size: .85rem;
    font-weight: 700;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.app-menu__action:hover {
    background: var(--orange-soft);
    color: var(--orange-dark);
}

@media (max-width: 380px) {
    body { font-size: 15px; }
    .container { width: calc(100% - 24px); }
    .tone-grid { grid-template-columns: 1fr 1fr; }
}

/* Tema alternativo (verde escuro) */
html[data-theme="flashmind"] {
    --bg: #f6fbf9;
    --card: #ffffff;
    --text: #103b36;
    --muted: #5f706c;
    --line: #d5e4df;
    --turquoise: #0b8f7f;
    --turquoise-dark: #087467;
    --turquoise-soft: #e3f3ef;
    --orange: #087467;
    --orange-dark: #075c53;
    --orange-soft: #e3f3ef;
    --shadow: 0 14px 40px rgba(16, 59, 54, .1);
}
html[data-theme="flashmind"] body {
    background:
      radial-gradient(circle at top left, #e3f3ef, transparent 42%),
      radial-gradient(circle at bottom right, #edf6f3, transparent 40%),
      #f6fbf9;
}
html[data-theme="flashmind"] .feature-card:hover {
    border-color: #b8ccc6;
}

/* Tema escuro (preferência do aluno) */
html[data-mode="dark"] {
    --bg: #121218;
    --card: #1c1c24;
    --text: #f2f2f5;
    --muted: #9a9aa8;
    --line: #2e2e3a;
    --turquoise-soft: #1a2e2a;
    --orange-soft: #2a2218;
    --shadow: 0 14px 40px rgba(0, 0, 0, .35);
}
html[data-theme="flashmind"][data-mode="dark"] {
    --orange-soft: #16332e;
    --turquoise-soft: #16332e;
}
html[data-mode="dark"] body {
    background: #121218;
}
html[data-mode="dark"] .feature-card,
html[data-mode="dark"] .card,
html[data-mode="dark"] .topbar,
html[data-mode="dark"] .app-menu__panel {
    background: var(--card);
    border-color: var(--line);
}
html[data-mode="dark"] .feature-card:hover {
    border-color: #4a4a58;
}
html[data-mode="dark"] .interval-form input:not([type="checkbox"]):not([type="radio"]),
html[data-mode="dark"] .interval-form select,
html[data-mode="dark"] .interval-form textarea,
html[data-mode="dark"] .material-textarea,
html[data-mode="dark"] .view-as-select {
    background: #16161e;
    color: var(--text);
    border-color: var(--line);
}
html[data-mode="dark"] .syllable-btn {
    background: #252530;
    color: #f2f2f5;
    border-color: var(--line);
}
html[data-mode="dark"] .syllable-btn:hover,
html[data-mode="dark"] .syllable-btn.is-active {
    background: var(--orange-soft);
    color: #92d5ca;
    border-color: var(--orange);
}
html[data-mode="dark"] .tone-btn {
    background: #2a2218;
    color: #92d5ca;
    border-color: #3d3224;
}
html[data-mode="dark"] .tone-btn:hover {
    background: var(--orange);
    color: #fff;
}
html[data-mode="dark"] .tone-sheet__panel,
html[data-mode="dark"] .modal__panel {
    background: var(--card);
    color: var(--text);
}
html[data-theme="flashmind"][data-mode="dark"] .syllable-btn:hover,
html[data-theme="flashmind"][data-mode="dark"] .syllable-btn.is-active {
    color: #92d5ca;
}
html[data-theme="flashmind"][data-mode="dark"] .tone-btn {
    background: #16332e;
    color: #92d5ca;
    border-color: #245048;
}

/* Demonstração (professor/admin home) */
.hx-demo-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  border: none;
  background: transparent;
  color: #8a9792;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 0.35rem 0.45rem;
  opacity: 0.72;
}
.hx-demo-fab[hidden] { display: none !important; }
.hx-demo-fab:hover { color: #087467; opacity: 1; }
.hx-demo-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: #0f1a17;
  display: flex;
  flex-direction: column;
}
.hx-demo-modal[hidden] { display: none !important; }
.hx-demo-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  z-index: 2;
  width: 2.4rem;
  height: 2.4rem;
  border: none;
  border-radius: 999px;
  background: rgba(255,255,255,.92);
  color: #17211f;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,.18);
}
.hx-demo-modal__frame {
  flex: 1;
  width: 100%;
  height: 100%;
  border: 0;
  background: #f4f8f6;
}
body.hx-demo-open { overflow: hidden; }
