:root {
  color-scheme: light;
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: #f3f0e8;
  color: #1e1b18;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(30, 27, 24, 0.05) 1px, transparent 1px),
    linear-gradient(180deg, rgba(30, 27, 24, 0.05) 1px, transparent 1px),
    #f3f0e8;
  background-size: 28px 28px;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  border: 2px solid #1e1b18;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 8px 8px 0 #1e1b18;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #1e1b18;
  padding-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #a23b24;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.05;
}

.mode-tabs,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab,
.primary,
.secondary,
.quick-button,
.palette-button {
  border: 2px solid #1e1b18;
  background: #fff;
  color: #1e1b18;
  cursor: pointer;
}

.tab,
.primary,
.secondary {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 900;
}

.tab.active,
.primary {
  background: #ffd84d;
}

.panel {
  display: none;
  padding-top: 22px;
}

.panel.active {
  display: block;
}

.compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border: 2px solid #1e1b18;
  padding: 14px;
  font-size: 18px;
  line-height: 1.5;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.quick-button {
  min-height: 56px;
  padding: 10px;
  background: #e4f1ed;
  font-weight: 800;
  line-height: 1.35;
}

.result-area,
.sentence-output {
  border: 2px solid #1e1b18;
  background: #fff;
  padding: 16px;
}

.section-title {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 900;
}

.glyph-output,
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  min-height: 168px;
}

.glyph-output.selected {
  min-height: 160px;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px dashed #777069;
}

.glyph-card {
  width: 118px;
  text-align: center;
}

.glyph-card img {
  display: block;
  width: 118px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 2px solid #1e1b18;
  background: #fbfaf6;
}

.glyph-card span {
  display: block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 900;
}

.note {
  min-height: 24px;
  margin: 12px 0 0;
  color: #a23b24;
  font-weight: 800;
}

.reverse-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(290px, 0.75fr);
  gap: 22px;
}

.palette {
  max-height: 560px;
  overflow: auto;
  padding-right: 8px;
}

.palette-button {
  padding: 8px;
}

.palette-button .glyph-card {
  width: 88px;
}

.palette-button .glyph-card img {
  width: 88px;
}

.sentence-output {
  margin-top: 12px;
  min-height: 72px;
  font-size: 20px;
  font-weight: 900;
  line-height: 1.45;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 1120px);
    padding: 14px 0;
  }

  .workspace {
    padding: 16px;
    box-shadow: 5px 5px 0 #1e1b18;
  }

  .topbar,
  .compose,
  .reverse-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .mode-tabs {
    width: 100%;
  }

  .tab,
  .primary {
    flex: 1;
    width: 100%;
  }
}
