/* Build: 20260712-grid7 */
:root {
  color-scheme: light;
  --paper: #fff9ec;
  --ink: #263238;
  --muted: #66747c;
  --line: #ead7aa;
  --accent: #ff7b54;
  --accent-dark: #cf4f31;
  --blue: #3f8cff;
  --green: #35a872;
  --sun: #ffd166;
  --panel: #ffffff;
  --shadow: 0 16px 34px rgba(88, 64, 28, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 209, 102, 0.42) 0 80px, transparent 82px),
    radial-gradient(circle at 88% 4%, rgba(110, 214, 255, 0.32) 0 96px, transparent 98px),
    linear-gradient(180deg, #fff8e8 0%, #f0fbff 100%);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.workspace {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 3px solid #ffe1a8;
  border-radius: 18px;
  background: linear-gradient(135deg, #fff8d7, #ffe7f0);
  color: var(--accent);
  font-size: 32px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(255, 123, 84, 0.18);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

.brand p {
  color: var(--muted);
  line-height: 1.35;
  font-size: 15px;
}

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
}

.search input {
  width: 100%;
  height: 52px;
  border: 2px solid #dfe8ef;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font-size: 26px;
  padding: 0 16px;
  outline: none;
}

.search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.14);
}

button {
  border: 0;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  min-height: 48px;
  padding: 0 18px;
  font-weight: 700;
  white-space: nowrap;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.search button {
  height: 52px;
  background: var(--accent);
  min-width: 104px;
}

.search .voice-button {
  display: grid;
  place-items: center;
  background: var(--blue);
  min-width: 74px;
  padding: 0 14px;
  font-size: 18px;
}

.content-grid {
  display: block;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(112, 90, 63, 0.13);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.eyebrow {
  display: block;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 4px;
}

.panel-head h2 {
  font-size: 34px;
  line-height: 1;
}

#currentChar {
  font-size: 66px;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  word-break: keep-all;
}

.radical-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-top: 5px;
  padding: 4px 10px;
  border: 1px solid rgba(47, 128, 237, 0.28);
  border-radius: 999px;
  background: #eef5ff;
  color: var(--blue);
  font-size: 17px;
  font-weight: 800;
}

.character-meaning {
  max-width: 520px;
  margin-top: 7px;
  color: #5f4630;
  font-size: 16px;
  line-height: 1.45;
  font-weight: 650;
}

.count-pill {
  display: grid;
  place-items: center;
  min-width: 82px;
  height: 42px;
  border-radius: 999px;
  background: #eaf8f0;
  color: var(--green);
  font-weight: 800;
}

.writer-stage {
  position: relative;
  min-height: 0;
  border-radius: 20px;
  background: #fffdfa;
  border: 2px solid #f0dfbd;
  padding: 10px;
}

.writer-target {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 16px;
  width: 100%;
  justify-content: center;
  align-items: center;
}

.writer-tile {
  display: grid;
  place-items: center;
  min-width: 0;
}

.writer-character {
  width: min(100%, 250px);
  aspect-ratio: 1;
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.controls button {
  min-height: 42px;
}

.controls button:nth-child(2) {
  background: var(--blue);
}

.study-tools {
  display: grid;
  gap: 10px;
  grid-column: 1;
  padding: 10px;
  border: 1px solid #f0dfbd;
  border-radius: 18px;
  background: #fffdfa;
}

.tool-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tool-actions button {
  min-height: 42px;
  padding: 0 12px;
}

.tool-actions button:first-child {
  background: var(--green);
}

.tool-actions button.is-favorite {
  background: #f4a62a;
}

.review-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.review-row h3 {
  margin: 0 0 6px;
  color: #6b5130;
  font-size: 14px;
  line-height: 1.2;
}

.char-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 38px;
  align-content: flex-start;
}

.char-chip {
  display: grid;
  place-items: center;
  width: auto;
  min-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid #e9d4a9;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(63, 45, 25, 0.06);
}

.writing-panel.is-multi-query {
  grid-template-columns: 1fr;
}

.writing-panel.is-multi-query .writer-stage,
.writing-panel.is-multi-query .controls,
.writing-panel.is-multi-query .study-tools {
  grid-column: 1;
}

.writing-panel.is-multi-query .word-list {
  display: none;
}

.char-chip.is-empty {
  width: auto;
  min-width: 96px;
  padding: 0 10px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  box-shadow: none;
}

.word-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  margin-top: 0;
}

.writing-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(300px, 1.05fr);
  gap: 12px;
}

.panel-head {
  grid-column: 1 / -1;
}

.writer-stage,
.controls,
.study-tools {
  grid-column: 1;
}

.word-list {
  grid-column: 2;
  grid-row: 2 / 4;
  align-self: start;
}

.word-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 76px;
  padding: 8px 12px;
  border: 1px solid #e4edf2;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 5px 12px rgba(63, 45, 25, 0.07);
}

.word-card .word-main {
  display: block;
  font-size: 25px;
  line-height: 1.1;
  font-weight: 800;
}

.word-card .word-pinyin {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.word-card .word-meaning {
  display: block;
  margin-top: 3px;
  color: #6b5130;
  font-size: 14px;
  line-height: 1.25;
  white-space: normal;
}

.word-card .word-meaning-label {
  color: var(--accent-dark);
  font-weight: 800;
}

.word-card .word-sound {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 14px;
  background: #eef7ff;
  color: var(--blue);
  font-size: 20px;
}

.word-card.is-loading .word-sound {
  background: #fff2d8;
  color: #b65d18;
}

.word-empty {
  min-height: 74px;
  padding: 18px;
  border: 1px dashed #d9c8a7;
  border-radius: 8px;
  background: #fffefa;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 860px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    min-width: 0;
  }

  .writer-stage {
    min-height: 0;
  }

  .writing-panel {
    grid-template-columns: 1fr;
  }

  .writer-stage,
  .controls,
  .study-tools,
  .word-list {
    grid-column: auto;
    grid-row: auto;
  }

  .word-list {
    margin-top: 0;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  h1 {
    font-size: 22px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    font-size: 30px;
  }

  .search {
    display: grid;
    grid-template-columns: 1fr 74px;
    align-items: stretch;
  }

  .search button {
    width: 100%;
  }

  .search button[type="submit"] {
    grid-column: 1 / -1;
  }

  .search .voice-button {
    width: 74px;
  }

  .controls {
    grid-template-columns: 1fr 1fr;
  }

  .review-row {
    grid-template-columns: 1fr;
  }

  .writer-target {
    grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
    gap: 12px;
  }

  .writer-character {
    width: min(100%, 190px);
  }
}

@media print {
  body {
    background: #fff;
  }

  body.print-practice .app-shell {
    display: none;
  }
}

/* Compact character grid */
body {
  background: #f3f7f8;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  padding: max(4px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.workspace {
  width: min(1180px, 100%);
}

.topbar {
  gap: 12px;
  padding: 2px 0 7px;
}

.brand {
  min-width: 248px;
  gap: 9px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-width: 2px;
  border-radius: 8px;
  font-size: 26px;
  box-shadow: none;
}

h1 {
  font-size: 20px;
}

.brand p {
  font-size: 13px;
}

.search input,
.search button {
  height: 44px;
}

.search input {
  border-radius: 8px;
  font-size: 22px;
}

.search button,
.search .voice-button {
  min-width: 58px;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 12px;
}

.search button[type="submit"] {
  min-width: 82px;
}

.panel,
.writing-panel {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.writer-stage {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.writer-target {
  display: grid;
  grid-template-columns: repeat(var(--columns, 1), minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

.writer-target[data-count="1"] {
  grid-template-columns: minmax(280px, 420px);
  justify-content: center;
}

.writer-tile {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  border: 1px solid #dce5e8;
  border-radius: 8px;
  background: #fff;
}

.writing-square,
.writer-character {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #d5a34a;
  border-radius: 4px;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), rgba(199, 145, 50, 0.68) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(199, 145, 50, 0.68) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(45deg, transparent calc(50% - 0.5px), rgba(199, 145, 50, 0.36) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(-45deg, transparent calc(50% - 0.5px), rgba(199, 145, 50, 0.36) 50%, transparent calc(50% + 0.5px)),
    #fffdfa;
  overflow: hidden;
}

.punctuation-square {
  display: grid;
  place-items: center;
  color: #263238;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 96px;
  font-weight: 700;
}

.character-meta {
  min-height: 25px;
  color: #42545c;
  font-size: 15px;
  font-weight: 750;
  text-align: center;
}

.tile-play {
  width: 100%;
  min-height: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: 6px;
  background: #ff704d;
  font-size: 15px;
}

.tile-words {
  display: grid;
  gap: 5px;
}

.tile-word {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid #dce8ed;
  border-radius: 6px;
  background: #f4f8fa;
  color: #263238;
  text-align: left;
}

.tile-word span {
  font-size: 18px;
  font-weight: 800;
}

.tile-word small {
  color: #66747c;
  font-size: 12px;
  font-weight: 650;
}

.auto-library {
  margin-top: 9px;
  padding: 7px 0 0;
  border-top: 1px solid #dce5e8;
}

.auto-library h3 {
  margin: 0 0 6px;
  color: #51636b;
  font-size: 13px;
}

.auto-library .char-chip {
  min-width: 34px;
  width: auto;
  height: 34px;
  min-height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 20px;
}

.writer-target.is-sentence {
  display: block;
}

.sentence-result {
  padding: 54px 18px 42px;
  border-top: 1px solid #dce5e8;
  border-bottom: 1px solid #dce5e8;
  background: #fff;
  text-align: center;
}

.sentence-line {
  color: #263238;
  font-family: "Kaiti SC", "STKaiti", "KaiTi", serif;
  font-size: 58px;
  font-weight: 700;
  line-height: 1.65;
  word-break: break-all;
}

.sentence-punctuation {
  color: #df4f31;
  font-size: 1.16em;
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
  }

  .writer-target,
  .writer-target[data-count="1"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .writer-target[data-count="1"] {
    grid-template-columns: minmax(0, 1fr);
    width: min(100%, 390px);
    margin: 0 auto;
  }

  .sentence-result {
    padding: 34px 12px 28px;
  }

  .sentence-line {
    font-size: 42px;
  }
}
