:root {
  --ink: #eef8f4;
  --muted: #9aa9a5;
  --line: #263c39;
  --paper: #091412;
  --panel: #101f1c;
  --panel-soft: #142722;
  --field: #07100f;
  --leaf: #4dd39d;
  --leaf-dark: #8df0c7;
  --gold: #f1bd55;
  --coral: #ff896f;
  --sky: #82d7ef;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(12, 43, 38, 0.84), rgba(9, 20, 18, 0.3) 42%),
    radial-gradient(circle at 14% 16%, rgba(77, 211, 157, 0.18), transparent 24rem),
    radial-gradient(circle at 82% 12%, rgba(255, 137, 111, 0.12), transparent 20rem),
    var(--paper);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 24px;
  padding: 24px;
}

.workspace,
.side-panel {
  min-width: 0;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-strip,
.editor-panel,
.visual-card,
.examples,
.sidebar-character-map,
.history,
.page-character-map {
  background: rgba(16, 31, 28, 0.9);
  border: 1px solid rgba(77, 211, 157, 0.18);
  box-shadow: var(--shadow);
}

.brand-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-radius: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--leaf);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: 1rem;
  line-height: 1.2;
}

.converter-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.panel-toolbar,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-toolbar {
  min-height: 58px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.output-toolbar {
  justify-content: flex-end;
}

label,
.slider-wrap span {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.output-actions {
  margin-left: auto;
}

.icon-button,
.text-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-weight: 700;
}

.icon-button {

  display: inline-grid;
  place-items: center;
  font-size: 1.1rem;
}

.text-button {
  padding: 0 14px;
}

a.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.inline-link {
  margin-top: 12px;
  color: #82d7ef;
}

.accent {
  border-color: rgba(77, 211, 157, 0.55);
  background: rgba(77, 211, 157, 0.14);
  color: var(--leaf-dark);
}

.text-button:hover,
.icon-button:hover,
.example-item:hover {
  border-color: var(--leaf);
  color: var(--leaf);
}

.subtle {
  color: var(--muted);
  background: var(--panel-soft);
}

#openCharacterMap {
  display: none;
}

textarea {
  width: 100%;
  resize: none;
  overflow: hidden;
  border: 0;
  outline: 0;
  padding: 22px;
  background: var(--field);
  color: var(--ink);
  font-size: 1.15rem;
  line-height: 1.65;
}

textarea::placeholder {
  color: #62716d;
}

.sinhala-text {
  font-family: "Noto Sans Sinhala", Inter, sans-serif;
  font-size: 1.1rem;
}

.output-panel {
  background:
    linear-gradient(180deg, rgba(77, 211, 157, 0.09), transparent 35%),
    rgba(16, 31, 28, 0.94);
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.visual-card,
.examples,
.sidebar-character-map,
.history,
.page-character-map {
  border-radius: 8px;
  padding: 16px;
}

.visual-card {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 14px;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(77, 211, 157, 0.18), rgba(255, 137, 111, 0.12)),
    var(--panel);
}

.visual-mark {
  width: 84px;
  aspect-ratio: 1;
  display: block;
  border-radius: 8px;
  object-fit: cover;
}

.visual-card p,
.history p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.example-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  overflow: hidden;
  transition: max-height 180ms ease, opacity 180ms ease, margin-top 180ms ease;
}

.examples.is-collapsed .example-list {
  max-height: 0;
  margin-top: 0;
  opacity: 0;
  pointer-events: none;
}

.example-item {
  width: 100%;
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  text-align: left;
  line-height: 1.35;
}

.example-item strong {
  display: block;
  margin-top: 5px;
  color: var(--leaf);
  font-family: "Noto Sans Sinhala", sans-serif;
}

.history ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
}

.history li {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.history button.history-item {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--leaf-dark);
  text-align: left;
  font-family: "Noto Sans Sinhala", sans-serif;
}

.history-source {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.78rem;
}

.about-shell {
  display: block;
  max-width: 980px;
}

.about-panel {
  min-height: auto;
}

.about-panel .panel-toolbar h2 {
  margin-bottom: 0;
}

.about-content {
  display: grid;
  gap: 14px;
  padding: 22px;
  background: var(--field);
}

.about-content p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  align-items: center;
  justify-items: end;
  padding: 20px;
  background: rgba(7, 16, 15, 0.72);
}

.modal-backdrop[hidden] {
  display: none;
}

.character-map {
  width: min(480px, 100%);
  max-height: min(640px, calc(100vh - 40px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(77, 211, 157, 0.24);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.character-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.character-map-header h2 {
  margin-bottom: 0;
}

.character-map-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.character-map-body {
  display: grid;
  gap: 14px;
  overflow: auto;
  padding: 14px;
}

.sidebar-character-map-body {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.page-character-map {
  grid-column: 1 / -1;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 180ms ease, transform 180ms ease;
}

.page-character-map[hidden] {
  display: none;
}

.page-character-map.is-hiding {
  opacity: 0;
  transform: translateY(12px);
}

.page-character-map-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
  gap: 14px;
  margin-top: 14px;
}

.page-character-map-list .character-map-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 15, 0.58);
}

.page-character-map-list .character-map-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.character-map-section h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.character-map-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.map-insert {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  text-align: left;
}

.map-insert:hover,
.map-insert:focus-visible {
  border-color: var(--leaf);
  color: var(--leaf);
}

.map-insert-key {
  font-weight: 800;
}

.map-insert-value {
  font-family: "Noto Sans Sinhala", Inter, sans-serif;
  font-size: 1rem;
  line-height: 1.2;
  text-align: right;
}

.sidebar-character-map .character-map-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.sidebar-character-map .map-insert {
  min-height: 36px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100vw - 40px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef8f4;
  color: #091412;
  box-shadow: var(--shadow);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

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

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .desktop-only {
    display: none;
  }

  .examples.is-collapsed .example-list {
    max-height: none;
    margin-top: 12px;
    opacity: 1;
    pointer-events: auto;
  }

}

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

  .brand-strip,
  .side-panel {
    grid-template-columns: 1fr;
  }

  #openCharacterMap {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-character-map {
    display: none;
  }

  .history {
    order: -1;
  }

  .modal-backdrop {
    place-items: center;
  }

  .character-map-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .brand-strip {
    align-items: flex-start;
  }

  textarea {
    font-size: 1rem;
  }

}
