/* Flower-paper name cards: warm colors, larger portraits, and centered seal glyphs. */
:root {
  font-size: 18px;
  --ink: #49382c; --ink-soft: #836d53; --paper: #fff5df; --card: #fffcf2;
  --line: #dfc395; --accent: #b64935; --accent-soft: #f9e0d1;
  --shadow: none; --radius: 10px; --jade: #38664e;
}
body { background: var(--paper); }
.blob { display: none; }
#app { width: min(100%, 1480px); height: 100%; height: 100dvh; max-height: 100dvh; padding: 14px 28px 10px; }
.topbar { padding: 0 0 10px; border: 0; }
.chip { padding: 6px 0; background: transparent; border-radius: 0; box-shadow: none; color: var(--jade); font-size: .85rem; }
.chip:hover { color: var(--accent); }
.home-head {
  position: relative; flex: 0 0 auto; text-align: left; padding: 20px 270px 18px 106px;
  margin: 0 2px 16px; border: 1px solid #dfba72; border-radius: 14px;
  background: #f9e5af; min-height: 138px; overflow: hidden;
}
.home-head::before { content: none; }
.home-head::after { content: ''; position: absolute; right: -10px; bottom: -4px; width: 290px; height: 154px; background: url('../images/name-garden.svg') right bottom / contain no-repeat; pointer-events: none; }
.hero-seal {
  position: absolute; left: 24px; top: 50%; transform: translateY(-50%);
  width: 60px; height: 68px; display: grid; place-items: center;
  background: var(--accent); color: #fff7dd; border: 1px solid #983e2f; border-radius: 9px 5px 10px 5px;
  outline: 1px solid #fff1c5; outline-offset: -5px;
}
.hero-seal > span { display: block; text-align: center; font-size: 2.3rem; line-height: 1; width: 1em; letter-spacing: 0; }
.home-head h1 { position: relative; z-index: 1; margin: 0; font-size: clamp(1.7rem, 3.3vw, 2.45rem); line-height: 1.2; color: #874331; letter-spacing: .08em; }
.home-head .english-title { color: #7a623c; font-size: .95rem; margin-top: 6px; letter-spacing: .03em; }
.home-head p { position: relative; z-index: 1; font-size: .76rem; color: #715e40; line-height: 1.45; margin: 9px 0 0; }
.class-filter { justify-content: flex-start; align-items: center; gap: 8px; padding: 0 3px 14px; }
.class-chip { border: 1px solid #d9bc86; border-radius: 8px; background: #fffbee; box-shadow: none; padding: 8px 14px; color: #766141; font-size: .8rem; font-weight: 700; }
.class-chip.on { background: var(--accent); color: #fff9e9; border-color: var(--accent); }
.class-chip:hover { border-color: var(--accent); }
.roster-count { margin-left: auto; color: var(--ink-soft); font-size: .73rem; }
.roster-scroll { padding: 4px 3px 22px; }
.roster-grid { grid-template-columns: repeat(auto-fill, minmax(166px, 1fr)); gap: 15px; }
.student-card {
  --card-tone: #b64935; --card-paper: #fff0df; --card-edge: #e6b68c;
  position: relative; display: grid; grid-template-columns: minmax(72px, 1fr) minmax(46px, .65fr);
  grid-template-rows: 78px minmax(48px, 1fr) 44px; gap: 10px 7px;
  height: 234px; padding: 18px 15px 13px; min-width: 0; align-items: center;
  background: var(--card-paper); border: 1px solid var(--card-edge); border-radius: 12px 12px 8px 8px;
  box-shadow: none; color: var(--ink); text-align: center;
}
.student-card:nth-child(4n+2) { --card-tone: #456e58; --card-paper: #eaf1da; --card-edge: #bacb95; }
.student-card:nth-child(4n+3) { --card-tone: #98641f; --card-paper: #fff0be; --card-edge: #e2bf68; }
.student-card:nth-child(4n+4) { --card-tone: #985459; --card-paper: #fae5df; --card-edge: #dfb2a6; }
.student-card::before { content: ''; position: absolute; inset: 6px; border: 1px solid var(--card-edge); border-radius: 8px 8px 4px 4px; pointer-events: none; }
.student-card::after { content: ''; position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: 25px; height: 3px; border-radius: 2px; background: var(--card-tone); pointer-events: none; }
.student-card:hover { border-color: var(--card-tone); outline: 2px solid var(--card-tone); outline-offset: -2px; }
.student-card:active { transform: none; filter: brightness(.97); }
.student-card .portrait { position: relative; width: 78px; height: 78px; display: grid; place-items: center; justify-self: center; border: 3px solid #fffaf0; outline: 1px solid var(--card-edge); border-radius: 50%; background: #f7dca9; color: var(--card-tone); font-size: 1.8rem; overflow: hidden; }
.student-card .pic { position: absolute; inset: 0; width: 100%; height: 100%; box-shadow: none; object-fit: cover; }
.student-card b { grid-column: 2; grid-row: 1 / 3; align-self: center; justify-self: center; writing-mode: vertical-rl; text-orientation: upright; color: var(--card-tone); font-size: 1.9rem; font-weight: normal; line-height: 1.25; letter-spacing: .1em; }
.student-card b .name-surname { color: inherit; }
.student-card .name-stamp { grid-column: 1; grid-row: 2; align-self: center; justify-self: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; width: 34px; height: 42px; padding: 4px 0; margin: 0; background: var(--card-tone); color: #fff9e5; border: 0; border-radius: 4px 2px 4px 2px; outline: 1px solid #fff2cc; outline-offset: -3px; writing-mode: horizontal-tb; letter-spacing: 0; }
.stamp-character { display: block; width: 100%; height: 16px; font-size: 14px; line-height: 16px; letter-spacing: 0; text-align: center; }
.student-card small { grid-column: 1 / -1; grid-row: 3; width: 100%; padding: 7px 0 0; border-top: 1px solid var(--card-edge); font-size: .68rem; line-height: 1.35; color: #6f5d43; text-align: center; overflow-wrap: anywhere; align-self: center; }
.student-card b.horizontal-name { writing-mode: horizontal-tb; font-size: 1rem; overflow-wrap: anywhere; }
.student-card.long-name b { font-size: 1.6rem; }
.detail { padding: 24px 0 20px; gap: 18px; }
.detail-columns { align-items: flex-start; gap: 28px; flex-wrap: wrap; }
.detail-head { background-image: none; display: grid; grid-template-columns: minmax(72px, 1fr) minmax(76px, 1fr); width: min(100%, 320px); padding: 22px; gap: 14px; border: 1px solid var(--line); border-top: 4px solid var(--accent); background: var(--card); border-radius: 10px; }
.detail-head > .pic { grid-column: 1; grid-row: 1; width: 86px; height: 86px; justify-self: center; box-shadow: none; border: 2px solid var(--paper); }
.name-row { grid-column: 2; grid-row: 1 / 3; display: flex; flex-direction: column; gap: 0; justify-self: center; align-self: start; border: 1px solid var(--line); }
.name-char { width: 62px; height: 62px; padding: 0; font-size: 2.25rem; font-weight: normal; border-radius: 0; box-shadow: none; background: #fff8e9; justify-content: center; border: 0; border-bottom: 1px dashed var(--line); }
.name-char.surname { color: var(--jade); border-bottom: 1px dashed var(--line); }
.name-char.given { color: var(--accent); border-bottom: 1px dashed var(--line); }
.name-char:last-child { border-bottom: 0; }
.name-char:hover { background: #eaf1da; }
.legend { grid-column: 1; grid-row: 2; flex-direction: column; align-self: start; gap: 8px; font-size: .65rem; }
.legend i { border-radius: 1px; }
.legend i.surname { background: var(--jade); }
.legend i.given { background: var(--accent); }
.detail-head > .action-row, .detail-head > .badge-btn, .detail-head > .teacher-note { grid-column: 1 / -1; }
.action-row { gap: 8px; }
.read-btn, .print-btn, .badge-btn { padding: 9px 12px; font-size: .75rem; line-height: 1.4; border: 1px solid var(--line); border-radius: 10px; box-shadow: none; justify-content: center; }
.read-btn { background: var(--accent); border-color: var(--accent); }
.print-btn, .badge-btn { color: var(--jade); background: transparent; }
.teacher-note { padding: 12px 0 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink-soft); border-radius: 0; text-align: left; font-size: .65rem; }
.detail-right { max-width: 720px; flex: 1 1 340px; gap: 14px; }
.meaning-title { margin: 0; color: var(--jade); font-size: 1.1rem; font-weight: normal; letter-spacing: .1em; }
.meaning-title small { margin-left: 12px; font-size: .7rem; color: var(--ink-soft); letter-spacing: 0; }
.meaning-grid { gap: 12px; }
.meaning-card { border: 1px solid var(--line); border-radius: 10px; padding: 18px; box-shadow: none; background: var(--card); gap: 16px; }
.meaning-card .glyph { border: 1px solid #e4ccc1; border-radius: 2px; width: 64px; height: 64px; font-size: 2.2rem; font-weight: normal; background: var(--accent-soft); color: var(--accent); }
.meaning-card.surname .glyph { border-color: #c7d5c7; color: var(--jade); background: #eaf1da; }
.meaning-card .tag { color: var(--jade); font-size: .65rem; }
.meaning-card .py-line { font-size: .8rem; }
.meaning-card .en { font-size: .83rem; line-height: 1.6; }
.meaning-card .write-btn { width: 50px; height: 50px; border-radius: 10px; font-size: 1.5rem; box-shadow: none; background: var(--jade); }
.badge-modal { border: 1px solid var(--line); border-radius: 4px; box-shadow: none; }
.badge-gate input, .badge-gate button, .badge-reveal img, .badge-warn, .badge-download, .badge-print { border-radius: 10px; box-shadow: none; }
.badge-gate input, .badge-print { border: 1px solid var(--line); }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.detail-head { background-color: #fff0d5; border-color: #ddb77c; border-radius: 12px; }
.detail-head > .pic { width: 96px; height: 96px; border: 4px solid #fffaf0; outline: 1px solid #dbbb85; }
.name-row { border: 1px solid #dec08b; border-radius: 8px; overflow: hidden; }
.meaning-title { color: #874331; font-size: 1.2rem; }
.meaning-card { background: #fffaf0; border-color: #dfc395; }
.meaning-card .glyph { background: #f7dfc6; }
.meaning-card.surname .glyph { background: #e8eed4; }
@media (max-width: 900px) {
  #app { padding: 12px 18px 8px; }
  .home-head { padding-right: 190px; }
  .home-head::after { width: 220px; height: 140px; right: -25px; }
  .roster-count { font-size: .68rem; }
}
@media (max-width: 600px) {
  #app { padding: 10px 12px 6px; }
  .topbar { padding-bottom: 8px; }
  .home-head { padding: 16px 12px 15px 72px; margin-bottom: 12px; min-height: 126px; border-radius: 10px; }
  .home-head::after { display: none; }
  .hero-seal { left: 14px; width: 44px; height: 54px; }
  .hero-seal > span { font-size: 1.9rem; }
  .home-head h1 { font-size: clamp(1.3rem, 5.8vw, 1.8rem); letter-spacing: .03em; }
  .home-head .english-title { font-size: .78rem; }
  .home-head p { font-size: .68rem; line-height: 1.4; margin-top: 8px; }
  .roster-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .student-card { grid-template-columns: minmax(58px, 1fr) minmax(40px, .65fr); height: 220px; padding: 15px 11px 12px; grid-template-rows: 68px minmax(44px, 1fr) 44px; gap: 8px 4px; }
  .student-card .portrait { width: 66px; height: 66px; }
  .student-card b { font-size: 1.65rem; }
  .student-card.long-name b { font-size: 1.35rem; }
  .student-card small { font-size: .62rem; }
  .class-filter { gap: 6px; padding-bottom: 10px; }
  .class-chip { padding: 8px 9px; font-size: .68rem; }
  .roster-count { flex-basis: 100%; margin: 2px 0 0; text-align: right; font-size: .65rem; }
  .detail { padding-top: 18px; }
  .detail-columns { gap: 20px; }
  .detail-head { width: 100%; max-width: 340px; padding: 18px; }
  .detail-right { flex-basis: 100%; }
  .meaning-card { padding: 12px; gap: 10px; }
  .meaning-card .glyph { width: 48px; height: 48px; font-size: 1.8rem; }
  .meaning-card .write-btn { width: 40px; height: 44px; flex-basis: 40px; }
  .meaning-card .en { font-size: .75rem; }
}

/* Keep the original return bar visible while the scoped name is loading. */
.topbar { min-height:52px; }
.name-loading { min-height:240px; display:grid; place-items:center; color:#7d735e; font-size:18px; text-align:center; }
