:root {
  --desktop: #3bb7b6;
  --desktop-dark: #168b8a;
  --window: #fff6bd;
  --panel: #f8d987;
  --panel-light: #fff1a8;
  --pink: #ff8fb3;
  --purple: #8d65c5;
  --red: #c13651;
  --blue: #2167aa;
  --ink: #241b22;
  --shadow: #7b5c46;
  --highlight: #ffffff;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.14) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.14) 75%) 0 0 / 18px 18px,
    linear-gradient(180deg, var(--desktop), var(--desktop-dark));
  font-family: "MS PGothic", Osaka, "Hiragino Maru Gothic ProN", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
}

a {
  color: var(--blue);
}

a:visited {
  color: var(--purple);
}

a:active {
  color: var(--red);
}

.desktop {
  min-height: 100vh;
  padding: 18px;
}

.app-window {
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  min-height: calc(100vh - 36px);
  margin: 0 auto;
  border: 4px solid var(--ink);
  background: var(--window);
  box-shadow:
    8px 8px 0 var(--shadow),
    inset 3px 3px 0 var(--highlight),
    inset -3px -3px 0 #d99e57;
}

.titlebar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 10px;
  color: #ffffff;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 2px, transparent 2px 6px),
    linear-gradient(90deg, var(--purple), var(--blue));
  border-bottom: 4px solid var(--ink);
}

.window-buttons {
  display: flex;
  gap: 5px;
}

.window-button {
  width: 18px;
  height: 18px;
  border: 2px solid var(--ink);
  background: var(--pink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.8);
}

.window-button:nth-child(2) {
  background: #ffe36e;
}

.window-button:nth-child(3) {
  background: #83de7d;
}

.title {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 24px;
  font-weight: bold;
  text-shadow: 2px 2px 0 #43236b;
}

.badge {
  padding: 3px 8px;
  border: 2px solid var(--ink);
  color: var(--ink);
  background: #ffe36e;
  box-shadow: inset 2px 2px 0 var(--highlight);
  font-size: 13px;
  font-weight: bold;
  white-space: nowrap;
}

.main-panel {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 14px;
  flex: 1;
  padding: 14px;
}

.side-panel,
.chat-panel {
  border: 3px solid var(--ink);
  background: var(--panel);
  box-shadow:
    inset 3px 3px 0 var(--highlight),
    inset -3px -3px 0 #b88246;
}

.side-panel {
  min-height: 260px;
  padding: 12px;
  text-align: center;
}

.mascot {
  position: relative;
  width: 96px;
  height: 112px;
  margin: 8px auto 12px;
  image-rendering: pixelated;
}

.mascot-screen {
  position: absolute;
  left: 14px;
  top: 8px;
  width: 68px;
  height: 54px;
  border: 4px solid var(--ink);
  background: #c9ffed;
  box-shadow: inset 4px 4px 0 #ffffff, inset -4px -4px 0 #8bc4b5;
}

.mascot-screen::before,
.mascot-screen::after {
  content: "";
  position: absolute;
  top: 20px;
  width: 8px;
  height: 8px;
  background: var(--ink);
}

.mascot-screen::before {
  left: 15px;
}

.mascot-screen::after {
  right: 15px;
}

.mascot-smile {
  position: absolute;
  left: 35px;
  top: 43px;
  width: 26px;
  height: 10px;
  border-bottom: 4px solid var(--ink);
}

.mascot-body {
  position: absolute;
  left: 6px;
  top: 62px;
  width: 84px;
  height: 42px;
  border: 4px solid var(--ink);
  background: #f2f0e6;
  box-shadow: inset 4px 4px 0 #ffffff, inset -4px -4px 0 #bdb8a6;
}

.mascot-disk {
  position: absolute;
  left: 22px;
  top: 74px;
  width: 26px;
  height: 18px;
  border: 3px solid var(--ink);
  background: var(--pink);
}

.mascot-light {
  position: absolute;
  right: 22px;
  top: 77px;
  width: 12px;
  height: 12px;
  border: 3px solid var(--ink);
  background: #83de7d;
}

.meter {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.meter-row {
  height: 16px;
  border: 2px solid var(--ink);
  background:
    repeating-linear-gradient(90deg, var(--pink) 0 10px, #ffe36e 10px 20px, #83de7d 20px 30px);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.8);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border-bottom: 3px solid var(--ink);
  background:
    radial-gradient(circle at 8px 8px, rgba(255, 255, 255, 0.8) 0 2px, transparent 3px) 0 0 / 18px 18px,
    var(--panel-light);
}

.tool-chip {
  min-height: 24px;
  padding: 2px 8px;
  border: 2px solid var(--ink);
  background: #ffffff;
  box-shadow: 2px 2px 0 #b88246;
  font-size: 13px;
  font-weight: bold;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

#chat-form {
  margin: 0;
  padding: 10px;
  border-bottom: 3px solid var(--ink);
  background: #f7bfd0;
}

.chat-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

#prompt {
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  border: 3px solid var(--ink);
  border-right-color: #ffffff;
  border-bottom-color: #ffffff;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  box-shadow: inset 3px 3px 0 #c7c7c7;
}

#prompt:disabled {
  color: #6a6660;
  background: #e9e2ce;
}

#send {
  min-width: 84px;
  min-height: 38px;
  padding: 6px 10px;
  border: 3px solid var(--ink);
  background: #ffe36e;
  color: var(--ink);
  font: inherit;
  font-weight: bold;
  box-shadow:
    inset 3px 3px 0 #fff7ba,
    inset -3px -3px 0 #d28b28,
    3px 3px 0 var(--shadow);
  cursor: pointer;
}

#send:active {
  transform: translate(2px, 2px);
  box-shadow:
    inset 2px 2px 0 #d28b28,
    inset -2px -2px 0 #fff7ba,
    1px 1px 0 var(--shadow);
}

#send:disabled {
  color: #716b61;
  background: #d8d1be;
  cursor: wait;
}

.messages-shell {
  flex: 1;
  padding: 10px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.32)),
    repeating-linear-gradient(0deg, #c7ecff 0 2px, #ffffff 2px 24px);
}

#messages {
  height: 100%;
  min-height: 360px;
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding: 10px;
  border: 3px solid var(--ink);
  background: #fffef3;
  box-shadow: inset 4px 4px 0 #c9c1a2;
}

[data-message-row] {
  position: relative;
  min-height: 46px;
  margin: 0 0 8px;
  padding: 10px 12px 10px 48px;
  border: 3px solid var(--ink);
  background: #ffffff;
  box-shadow: 4px 4px 0 #b7a37c;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

[data-message-row]::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 22px;
  height: 22px;
  border: 3px solid var(--ink);
  background:
    linear-gradient(90deg, transparent 40%, rgba(36, 27, 34, 0.25) 40% 60%, transparent 60%),
    #ffe36e;
  box-shadow: inset 3px 3px 0 #fff7ba;
}

.message-meta {
  display: inline;
}

[data-message-name] {
  display: inline-block;
  margin-right: 2px;
  color: var(--blue) !important;
  font-weight: bold;
}

[data-message-arrow] {
  color: var(--purple) !important;
  font-weight: bold;
}

[data-message-body] {
  display: inline;
  color: inherit;
}

[data-message-row][data-message-role="assistant"] [data-message-body] {
  color: #900000;
}

[data-message-row][data-message-tone="thinking"] [data-message-body] {
  color: #800000;
}

[data-message-row][data-message-tone="error"] [data-message-body] {
  color: var(--red);
  font-weight: bold;
}

#messages [data-message-body] p {
  display: inline;
  margin: 0;
}

#messages [data-message-body] p + p {
  display: block;
  margin-top: 0.5em;
}

#messages [data-message-body] table {
  border-collapse: collapse;
  margin: 0.5em 0;
  background: #ffffff;
}

#messages [data-message-body] th,
#messages [data-message-body] td {
  border: 2px solid currentColor;
  padding: 2px 6px;
}

#messages hr {
  height: 6px;
  margin: 10px 0;
  border: 0;
  background:
    repeating-linear-gradient(90deg, var(--pink) 0 12px, #ffe36e 12px 24px, #83de7d 24px 36px, var(--purple) 36px 48px);
}

.footer-strip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 3px solid var(--ink);
  background: #f2f0e6;
  font-size: 13px;
  font-weight: bold;
}

.sparkle {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  border: 2px solid var(--ink);
  background: var(--pink);
  vertical-align: -2px;
  box-shadow: 5px 0 0 #ffe36e, 10px 0 0 #83de7d;
}

@media (max-width: 700px) {
  .desktop {
    padding: 10px;
  }

  .app-window {
    min-height: calc(100vh - 20px);
    box-shadow: 5px 5px 0 var(--shadow);
  }

  .titlebar {
    grid-template-columns: 1fr auto;
  }

  .window-buttons {
    display: none;
  }

  .title {
    font-size: 19px;
  }

  .badge {
    font-size: 12px;
  }

  .main-panel {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .side-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 0;
    text-align: left;
  }

  .mascot {
    width: 86px;
    height: 98px;
    margin: 0 10px 0 0;
  }

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

  #send {
    width: 100%;
  }

  #messages {
    min-height: 330px;
    max-height: none;
  }
}
