:root {
  --ink: #24221d;
  --muted: #716b61;
  --line: rgba(55, 48, 38, .14);
  --saffron: #d58a2b;
  --leaf: #5f8067;
  --paper: #fffaf0;
  --ground: #f1e7d7;
  --white: #fffef9;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(140deg, rgba(213, 138, 43, .16), transparent 38%),
    linear-gradient(320deg, rgba(95, 128, 103, .22), transparent 42%),
    var(--ground);
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

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

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  color: var(--ink);
  font: 650 28px Georgia, serif;
  text-decoration: none;
}

.brand span {
  color: var(--saffron);
}

.language-switcher {
  display: flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid rgba(255, 254, 249, .6);
  border-radius: 999px;
  background: rgba(255, 254, 249, .52);
}

.language-button {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  filter: saturate(.72);
  opacity: .62;
}

.language-button.active {
  background: var(--white);
  box-shadow: 0 4px 14px rgba(82, 65, 43, .14);
  filter: none;
  opacity: 1;
}

.install-button {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 254, 249, .72);
  font-size: 22px;
}

.install-button.available {
  display: block;
}

.oracle {
  align-self: center;
  text-align: center;
  padding: 28px 0 44px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #8b642f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
}

h1 {
  margin: 0;
  font: 650 clamp(48px, 8vw, 88px) Georgia, serif;
  line-height: .96;
}

.intro {
  width: min(610px, 100%);
  margin: 22px auto 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.install-help {
  width: min(520px, 100%);
  margin: 20px auto 0;
  border: 1px solid rgba(95, 128, 103, .22);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 254, 249, .7);
  text-align: left;
}

.install-help strong {
  display: block;
  margin-bottom: 5px;
  color: var(--leaf);
  font-weight: 800;
}

.install-help p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.focus-ring {
  width: min(330px, 74vw);
  aspect-ratio: 1;
  margin: 38px auto 22px;
  --wait-ms: 2200ms;
  border: 1px solid rgba(120, 91, 48, .18);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  background: rgba(255, 254, 249, .42);
  box-shadow: inset 0 0 0 18px rgba(255, 254, 249, .28), 0 26px 70px rgba(89, 70, 43, .13);
}

.halo {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  position: absolute;
  background: radial-gradient(circle at 34% 28%, #ffe3a9, #d58a2b 58%, #956321);
  box-shadow: 0 18px 42px rgba(169, 103, 32, .22);
}

.focus-ring.waiting .halo {
  animation: breathe 1.15s ease-in-out infinite alternate;
}

.focus-ring.waiting .answer-number {
  opacity: 0;
}

.focus-ring.waiting .thinking-progress {
  opacity: 1;
}

@keyframes breathe {
  to {
    transform: scale(.88);
    filter: brightness(1.08);
  }
}

.answer-number {
  z-index: 1;
  min-height: 92px;
  color: white;
  font: 650 78px Georgia, serif;
  text-shadow: 0 3px 18px rgba(50, 32, 12, .26);
}

.status {
  z-index: 1;
  position: absolute;
  bottom: 74px;
  color: rgba(255, 255, 255, .84);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.thinking-progress {
  z-index: 2;
  position: absolute;
  inset: 9px;
  width: auto;
  height: auto;
  opacity: 0;
  pointer-events: none;
  transform: rotate(-90deg);
  transition: opacity .18s ease;
}

.progress-track,
.progress-meter {
  fill: none;
  stroke-width: 2.7;
}

.progress-track {
  stroke: rgba(255, 255, 255, .24);
}

.progress-meter {
  stroke: rgba(255, 255, 255, .92);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  stroke-linecap: round;
}

.focus-ring.waiting .progress-meter {
  animation: circle-progress var(--wait-ms) linear forwards;
}

@keyframes circle-progress {
  to {
    stroke-dashoffset: 0;
  }
}

.primary {
  min-height: 54px;
  border: 0;
  border-radius: 999px;
  padding: 0 28px;
  background: var(--ink);
  color: white;
  box-shadow: 0 14px 34px rgba(36, 34, 29, .24);
  font-weight: 800;
}

.primary:disabled {
  opacity: .72;
}

.answer-panel,
.history {
  border: 1px solid rgba(255, 254, 249, .72);
  border-radius: 8px;
  background: rgba(255, 254, 249, .72);
  box-shadow: 0 18px 50px rgba(82, 65, 43, .1);
}

.answer-panel {
  width: min(700px, 100%);
  margin: 28px auto 0;
  padding: 26px;
  text-align: left;
}

.answer-meta {
  color: #8b642f;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.answer-panel p {
  margin: 12px 0 0;
  font: 500 clamp(21px, 4vw, 32px) Georgia, serif;
  line-height: 1.42;
}

.history {
  align-self: center;
  padding: 22px;
}

.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.history h2 {
  margin: 0;
  font: 650 22px Georgia, serif;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--leaf);
  font-weight: 800;
  padding: 6px 0;
}

.text-button:disabled {
  opacity: .38;
}

.history ol {
  list-style: none;
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
}

.history li {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  align-items: start;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history li:first-child {
  border-top: 0;
}

.history li button {
  width: 44px;
  height: 44px;
  border: 1px solid rgba(95, 128, 103, .24);
  border-radius: 50%;
  background: #edf3ea;
  color: #405f48;
  font-weight: 800;
}

.history p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.footer-bar {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
  justify-self: center;
  padding: 2px 10px 8px;
}

.share-button {
  min-height: 36px;
  border: 1px solid rgba(95, 128, 103, .22);
  border-radius: 999px;
  padding: 0 16px;
  background: rgba(255, 254, 249, .7);
  color: var(--leaf);
  font-weight: 800;
}

.watermark,
.app-version {
  color: rgba(36, 34, 29, .42);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .4px;
}

.watermark {
  user-select: all;
}

.app-version {
  border: 1px solid rgba(36, 34, 29, .12);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 254, 249, .36);
  user-select: text;
}

.share-dialog {
  width: min(360px, calc(100% - 32px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(36, 34, 29, .28);
}

.share-dialog::backdrop {
  background: rgba(36, 34, 29, .42);
  backdrop-filter: blur(4px);
}

.share-dialog form {
  padding: 20px;
}

.share-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.share-heading strong {
  display: block;
  font: 650 22px Georgia, serif;
}

.share-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.share-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 254, 249, .8);
  font-size: 24px;
  line-height: 1;
}

.share-qr {
  display: block;
  width: min(100%, 292px);
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  background: white;
}

.author-dialog {
  width: min(620px, calc(100% - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(36, 34, 29, .28);
}

.author-dialog::backdrop {
  background: rgba(36, 34, 29, .42);
  backdrop-filter: blur(4px);
}

.author-card {
  display: grid;
  gap: 13px;
  padding: 24px;
}

.author-card h2,
.author-card h3,
.author-card p {
  margin: 0;
}

.author-card h2 {
  font: 650 30px Georgia, serif;
}

.author-card h3 {
  margin-top: 4px;
  font: 650 18px Georgia, serif;
}

.author-card label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 800;
}

.author-card input,
.author-card textarea {
  width: 100%;
  border: 1px solid rgba(55, 48, 38, .22);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 254, 249, .9);
  font: inherit;
}

.author-card textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.5;
}

.author-message-body {
  min-height: 150px;
  border: 1px solid rgba(95, 128, 103, .16);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 254, 249, .52);
  color: var(--ink);
  font-size: 18px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.author-muted,
.author-note {
  color: var(--muted);
  line-height: 1.5;
}

.author-note {
  border: 1px solid rgba(95, 128, 103, .18);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 254, 249, .5);
  font-size: 14px;
}

.author-check {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  font-weight: 700 !important;
}

.author-check input {
  width: auto;
}

.author-required {
  color: #9a4a00;
  font-weight: 800;
}

.author-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.author-actions button,
.author-download {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 18px;
  background: rgba(255, 254, 249, .86);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.author-primary,
.author-download {
  border-color: transparent !important;
  background: var(--ink) !important;
  color: white !important;
}

.author-primary:disabled {
  opacity: .38;
}

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

  .oracle {
    padding-top: 18px;
  }

  .history {
    width: min(700px, 100%);
    justify-self: center;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding: 18px 14px 28px;
  }

  .intro {
    font-size: 15px;
  }

  .focus-ring {
    margin-top: 30px;
  }

  .status {
    bottom: 62px;
  }

  .thinking-progress {
    inset: 8px;
  }

  .answer-panel {
    padding: 22px;
  }
}
