/* The app's own styles sit in a cascade layer, so the card editor's scoped
   card styles (unlayered) always win over them inside a card. See editor.js. */
@layer app {
/* The note editor: a card you write on. */

.wy { display: grid; gap: 14px; }
.wy__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wy__top-right { display: flex; align-items: center; gap: 8px; }
.wy__deck .select { min-width: 190px; height: 36px; }
.wy__help { color: var(--text-muted); font: var(--type-caption); margin-top: -6px; }
.wy__cards { min-height: 1.2em; margin-top: -4px; }

/* ---------- the card ---------- */

.wy-card__band { height: 40px; }
.wy-card__emblem { position: absolute; left: 18px; bottom: 9px; font: 600 20px/1 var(--font); color: rgba(255, 255, 255, 0.92); }
.wy-card__emblem.is-cjk { font: 800 22px/1 var(--font-mincho); transform: none; bottom: 8px; }

.wy-face-wrap { position: relative; }
.wy-face-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 18px 0;
}
/* The back and extra open with the same dashed rule a study card draws
   between question and answer, with the face's name on it. */
.wy-face-bar--rule { margin: 4px 18px 0; padding-top: 8px; border-top: 1px dashed var(--border); }
.wy-face-label { font: var(--type-label); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-faint); }
.wy-face-tools { display: flex; gap: 2px; opacity: 0; transition: opacity var(--quick); }
.wy-face-wrap:hover .wy-face-tools, .wy-face-wrap:focus-within .wy-face-tools, .wy-face-wrap.is-html .wy-face-tools { opacity: 1; }
@media (hover: none) { .wy-face-tools { opacity: 1; } }
.wy-tool {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px; border-radius: 7px;
  color: var(--text-muted); font: 600 12px/1 var(--font);
  transition: background-color var(--quick), color var(--quick);
}
.wy-tool:hover { background: var(--surface-hover); color: var(--text); }
.wy-tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* The face carries the card's own styles (scoped in by the editor); this is
   only its frame. */
.wy-face { padding: 10px 24px 22px; min-height: 120px; cursor: text; transition: background-color var(--quick);
  /* Nothing a card or its deck styles can draw outside the card. */
  contain: paint; position: relative; isolation: isolate; }
.wy-face.is-drop { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -8px; border-radius: 12px; }
.wy-edit { outline: none; min-height: 1.6em; caret-color: var(--accent); }
.wy-edit:empty::before { content: attr(data-placeholder); color: var(--text-muted); opacity: 0.8; font-size: 0.72em; font-family: var(--font); font-weight: 400; letter-spacing: 0; pointer-events: none; }
[data-face-wrap="extra"] .wy-face { min-height: 80px; }
[data-face-wrap="extra"] .wy-face .card { font-size: 0.74em; color: var(--text-dim); }
/* !important: the card's own styles (unlayered, so they beat the app's) give
   the face display:block; a collapsed or HTML-mode face must still hide. */
.wy-face-wrap.is-collapsed .wy-face-bar, .wy-face-wrap.is-collapsed .wy-face, .wy-face-wrap.is-collapsed .wy-source { display: none !important; }
.wy-face-wrap:not(.is-collapsed) .wy-reveal { display: none; }
.wy-reveal {
  display: flex; align-items: center; gap: 6px; width: 100%; padding: 10px 18px 14px; margin-top: 4px;
  border-top: 1px dashed var(--border-soft); color: var(--text-muted); font: 550 12.5px/1.3 var(--font); text-align: left;
}
.wy-reveal:hover { color: var(--accent); }
.wy-reveal .muted { font-weight: 400; }
.wy-face-wrap.is-html .wy-face { display: none !important; }
.wy-source { display: none; margin: 8px 18px 16px; width: calc(100% - 36px); min-height: 140px; }
.wy-face-wrap.is-html .wy-source { display: block; }
.wy-err { margin: -8px 18px 12px; }
.wy[aria-busy="true"] .wy-face { opacity: 0.6; }

/* Clozes are lit as they're typed: each editor styles its own highlight (editor.js). */

/* ---------- the floating toolbar ---------- */

.wy-bubble {
  position: fixed; z-index: 220;
  display: flex; align-items: center; gap: 1px; padding: 4px;
  border-radius: 12px; background: var(--surface-active); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.12s var(--ease-out);
}
.wy-bubble::after {
  content: ""; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; margin-left: -5px;
  background: var(--surface-active); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}
.wy-bubble.is-below::after { bottom: auto; top: -6px; transform: rotate(225deg); }
.wy-bubble__btn { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--text-dim); transition: background-color var(--quick), color var(--quick); }
.wy-bubble__btn .icon { width: 17px; height: 17px; }
.wy-bubble__btn:hover { background: var(--surface-hover); color: var(--text); }
.wy-bubble__btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }
.wy-bubble__sep { width: 1px; height: 18px; margin: 0 3px; background: var(--border); }
@media (max-width: 640px) { .wy-bubble { flex-wrap: wrap; max-width: calc(100vw - 16px); justify-content: center; } .wy-bubble::after { display: none; } }

/* ---------- shared bits ---------- */

.tags-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: var(--control); padding: 5px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--bg-elevated); cursor: text;
}
.tags-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tags-input__field { flex: 1; min-width: 160px; border: 0; background: transparent; height: 28px; padding: 0 6px; outline: none; }
.tags-input__field::placeholder { color: var(--text-muted); opacity: 0.85; }
.tag-chip { display: inline-flex; align-items: center; gap: 2px; height: 26px; padding: 0 4px 0 10px; border-radius: 7px; background: var(--surface-active); color: var(--text-dim); font: 550 13px/1 var(--font); }
.tag-chip::before { content: "#"; color: var(--text-faint); margin-right: 1px; }
.tag-chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; color: var(--text-faint); }
.tag-chip button:hover { background: var(--surface-hover); color: var(--text); }
.wy__tags { display: grid; gap: 8px; }

/* Content inside the editable card is styled by the editor's own scoped stylesheet. */
@keyframes spin { to { transform: rotate(360deg); } }

.palette { display: grid; grid-template-columns: repeat(5, 30px); gap: 8px; }
.palette__sw { width: 30px; height: 30px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); transition: transform var(--quick); }
.palette__sw:hover, .palette__sw:focus-visible { transform: scale(1.1); }
.palette__sw.is-none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45% 55%, transparent 55%), var(--surface-2); }
.size-list { display: grid; min-width: 160px; }
.mini-form { display: grid; gap: 8px; min-width: 260px; }
.mini-form__row { display: flex; gap: 8px; }

.preview { display: grid; gap: 12px; }
.preview__bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.preview__cards { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.preview__cards .chip { cursor: pointer; }

/* The add page: one column, the card at a comfortable reading width. */
.add-layout { max-width: 820px; margin: 0 auto; }
}
