:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, "Segoe UI", sans-serif;
  color: #292622;
  background: #f5f2ed;
  --line: #ddd7ce;
  --card: #fffcf8;
  --muted: #645c54;
  --accent: #814f42;
  --blue: #245b7b;
}

* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #226d99;
  outline-offset: 2px;
}

.shell { width: min(86rem, 100%); margin: auto; padding: 2.25rem clamp(1rem, 3.5vw, 3rem) 2rem; }
.masthead { display: flex; align-items: end; justify-content: space-between; gap: 0.75rem; }
.studio { margin: 0 0 0.25rem; font-weight: 650; color: var(--accent); }
h1 { font: 400 clamp(2rem, 4.5vw, 3.65rem)/1.05 Georgia, serif; margin: 0; letter-spacing: -0.035em; }
.reset { padding: 0.45rem 0.85rem; background: var(--card); border: 1px solid var(--line); border-radius: 0.45rem; color: inherit; white-space: nowrap; }
.reset:hover { background: #eee8de; }
.notice { margin: 1.1rem 0 1.4rem; padding: 0.6rem 0.8rem; border-left: 2px solid #ac7f70; color: var(--muted); background: #eee8e0; font-size: 0.875rem; }
#status { color: var(--accent); font-size: 0.875rem; }

.workspace { display: grid; grid-template-columns: minmax(19rem, 0.83fr) minmax(0, 1.65fr); align-items: start; gap: 1rem; }
.card { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 0.9rem; background: var(--card); box-shadow: 0 8px 24px #382a1810; }
.card-heading { min-height: 3.25rem; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.55rem 0.95rem; border-bottom: 1px solid var(--line); }
.card-heading h2 { margin: 0; font-size: 0.96rem; font-weight: 650; }
.languages { display: flex; gap: 0.22rem; }
.languages button { padding: 0.2rem 0.45rem; border-radius: 0.35rem; border: 1px solid transparent; background: transparent; font-size: 0.78rem; color: var(--muted); }
.languages button:hover { background: #f0eae1; }
.languages [aria-pressed="true"] { background: #e9ded4; color: #53362c; border-color: #d6c6b8; }

.chat, .panel { height: clamp(32rem, 69vh, 47rem); }
.chat { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.chat-heading { display: flex; align-items: center; gap: 0.7rem; padding: 0.7rem 0.85rem; color: #16374e; background: #f5faff; border-bottom: 1px solid #c4d6e5; }
.chat-heading small { display: block; color: #46657b; }
.avatar { display: grid; place-items: center; width: 2.35rem; height: 2.35rem; border-radius: 50%; background: #2b6e92; color: white; font: 1.35rem Georgia, serif; }
.history {
  display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; overflow: auto;
  padding: 1rem 0.8rem;
  background: radial-gradient(circle at 6px 6px, #7d9fb638 1px, transparent 1.5px) 0 0 / 24px 24px, linear-gradient(145deg, #eaf1f5, #d9e7ef);
}
.history > * { flex: none; }
.bubble { max-width: 94%; padding: 0.62rem 0.78rem; border-radius: 0.8rem 0.8rem 0.8rem 0.22rem; background: #fff; color: #17374a; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.875rem; box-shadow: 0 1px 2px #27455924; }
.bubble.outgoing { align-self: end; border-radius: 0.8rem 0.8rem 0.22rem 0.8rem; background: #c6e9d8; color: #23483a; }
.inline-keys, .keyboard { display: grid; gap: 0.23rem; }
.inline-keys { width: 100%; }
.inline-keys > div, .keyboard > div { display: flex; gap: 0.23rem; }
.inline-keys button, .keyboard button { flex: 1; min-width: 0; padding: 0.43rem 0.26rem; border-radius: 0.38rem; font-size: 0.8rem; }
.inline-keys button { border: 1px solid #b0c8da; background: #f6fbfe; color: var(--blue); }
.inline-keys button:hover { background: #cde2f1; }
.keyboard { padding: 0.6rem; border-top: 1px solid #c4d6e5; background: #f5faff; }
.keyboard:empty { display: none; }
.keyboard button { border: 1px solid #a3c3d7; background: #e0f0fa; font-weight: 600; color: #1e4d6e; }
.keyboard button:hover { background: #c7e4f5; }

[aria-busy="true"] .workspace { cursor: progress; }

@media (max-width: 53rem) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .chat { height: clamp(27rem, 72vh, 38rem); }
}

@media (max-width: 30rem) {
  .masthead { align-items: start; }
  .reset { font-size: 0.8rem; }
}
