:root {
  color-scheme: dark;
  --bg: #161319;
  --panel: #24202b;
  --panel-deep: #1d1924;
  --ink: #f9eed8;
  --muted: #b6a891;
  --line: #4b4057;
  --accent: #f7c85f;
  --accent-deep: #d9893d;
  --user: #365d69;
  --assistant: #3c3152;
  --shadow: #0a0810;
  --radius: 8px;
  font-family: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 16px 16px;
  color: var(--ink);
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(0, 3fr);
  gap: 18px;
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  align-items: stretch;
}

.chat-panel,
.room-panel {
  min-width: 0;
  background: var(--panel);
  border: 4px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 0 var(--shadow);
}

.chat-panel {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 640px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  background: var(--panel-deep);
  border-bottom: 4px solid var(--line);
}

.panel-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  letter-spacing: 0;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px 14px;
  background: #18131f;
  border-bottom: 4px solid var(--line);
}

.mode-tab {
  min-height: 38px;
  color: var(--ink);
  background: #2f2840;
  border: 2px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
}

.mode-tab.active {
  color: var(--shadow);
  background: var(--accent);
  border-color: var(--shadow);
}

.panel-view {
  display: none;
  min-height: 0;
}

.panel-view.active {
  display: block;
}

.ghost-button,
#sendButton {
  min-height: 44px;
  padding: 0 16px;
  color: var(--shadow);
  background: var(--accent);
  border: 3px solid var(--shadow);
  border-radius: 4px;
  box-shadow: 0 5px 0 var(--accent-deep);
  cursor: pointer;
}

.ghost-button:hover,
#sendButton:hover {
  transform: translateY(1px);
  box-shadow: 0 4px 0 var(--accent-deep);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 18px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 120px),
    var(--panel);
}

#chatPanel.active {
  display: grid;
  min-height: 0;
}

.settings-panel {
  padding: 18px;
  overflow-y: auto;
  background: var(--panel);
}

.setting-field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.setting-field input,
.setting-field select,
.setting-field textarea {
  width: 100%;
  padding: 12px;
  color: var(--ink);
  background: #17131f;
  border: 3px solid var(--line);
  border-radius: 4px;
  outline: none;
}

.setting-field textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.55;
}

.setting-note,
.setting-status {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.settings-button {
  min-height: 42px;
  padding: 0 14px;
  margin: 0 8px 12px 0;
  color: var(--shadow);
  background: var(--accent);
  border: 3px solid var(--shadow);
  border-radius: 4px;
  box-shadow: 0 4px 0 var(--accent-deep);
  cursor: pointer;
}

.message {
  width: min(86%, 560px);
  padding: 12px;
  border: 3px solid var(--line);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--shadow);
}

.message p {
  margin: 8px 0 0;
  line-height: 1.55;
}

.message-author {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.message.assistant {
  align-self: flex-start;
  background: var(--assistant);
}

.message.user {
  align-self: flex-end;
  background: var(--user);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px;
  background: var(--panel-deep);
  border-top: 4px solid var(--line);
}

#chatInput {
  width: 100%;
  min-height: 64px;
  max-height: 180px;
  resize: vertical;
  padding: 12px;
  color: var(--ink);
  background: #17131f;
  border: 3px solid var(--line);
  border-radius: 4px;
  outline: none;
}

#chatInput:focus {
  border-color: var(--accent);
}

#sendButton {
  align-self: end;
  min-width: 92px;
}

.room-panel {
  min-height: 640px;
  overflow: hidden;
  background: #0a0e1a;
}

.cat-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 632px;
  border: 0;
  background: #0a0e1a;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100vw - 20px, 680px);
    padding: 12px 0 18px;
  }

  .chat-panel,
  .room-panel {
    min-height: auto;
  }

  .chat-panel {
    min-height: 560px;
  }

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

  #sendButton {
    width: 100%;
  }

  .message {
    width: min(94%, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
