:root {
  --bg: #181818;
  --panel: #272729;
  --panel-2: #2d2d2c;
  --border: #454545;
  --muted: #8c8c8c;
  --text: #ffffff;
  --subtext: #a8aeb5;
  --blue: #2b7fff;
  --bubble-user: #282828;
  --bubble-assistant: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Rubik, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(24, 24, 24, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 32px 44px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-subtitle {
  color: var(--subtext);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.7px;
}

.ioriver-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ioriver-logo-icon {
  display: grid;
  place-items: center;
}

.ioriver-logo-wordmark {
  display: flex;
  align-items: center;
  gap: 0;
}

.ioriver-logo svg {
  display: block;
}

.prompt-pill {
  font-size: 12px;
  color: var(--subtext);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 10px;
  border-radius: 999px;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 12px 16px 0;
}

.chat {
  width: 100%;
  max-width: 894px;
  padding: 8px 0 24px;
}

.msg {
  display: flex;
  gap: 12px;
  margin: 14px 0;
}

.msg.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 100%;
  border-radius: 12px;
  padding: 16px 20px;
  line-height: 1.4;
  font-size: 16px;
}

.msg.user .bubble {
  background: var(--bubble-user);
}

.msg.assistant .bubble {
  background: var(--bubble-assistant);
  padding-left: 0;
  padding-right: 0;
}

.bubble p {
  margin: 0 0 10px;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble a {
  color: #9ec2ff;
  text-decoration: none;
}

.bubble a:hover {
  text-decoration: underline;
}

.bubble pre {
  margin: 12px 0;
  padding: 16px 18px;
  background: #060606;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  overflow: auto;
}

.bubble :not(pre) > code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 4px;
}

.bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-size: 0.95em;
}

.bubble h1,
.bubble h2,
.bubble h3,
.bubble h4 {
  margin: 18px 0 10px;
  font-weight: 600;
}

.bubble ul,
.bubble ol {
  margin: 8px 0 12px 22px;
  padding: 0;
}

.bubble li {
  margin: 6px 0;
}

.bubble blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  border-left: 4px solid #424242;
  color: rgba(255, 255, 255, 0.92);
}

.bubble blockquote p {
  margin: 0;
}

.bubble hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
  margin: 18px 0;
}

.code-block {
  margin: 12px 0;
  background: #060606;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 12px 0;
}

.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-family: Rubik, system-ui, sans-serif;
  font-size: 12px;
  line-height: 14.4px;
  cursor: pointer;
  border-radius: 4px;
}

.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.code-block-body pre {
  margin: 0;
  padding: 24px;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.code-block-body code {
  font-family: Rajdhani, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
    monospace;
  font-weight: 500;
}

.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.bubble th,
.bubble td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
}

.bubble th {
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
}

.composer-wrap {
  position: sticky;
  bottom: 0;
  z-index: 18;
  background: rgba(24, 24, 24, 0.92);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 12px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.composer {
  width: 100%;
  max-width: 894px;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 14px 14px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.composer-input {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  min-height: 26px;
  max-height: 160px;
}

.composer-input::placeholder {
  color: var(--muted);
}

.send-btn {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.send-btn .icon-disabled {
  display: none;
}

.send-btn:disabled .icon-enabled {
  display: none;
}

.send-btn:disabled .icon-disabled {
  display: block;
}

.send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.cancel-btn {
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.cancel-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.composer.disabled {
  opacity: 0.9;
}

.composer-hint {
  width: 100%;
  max-width: 894px;
  font-size: 12px;
  color: var(--subtext);
  min-height: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 13, 0.1);
  backdrop-filter: blur(1px);
  display: grid;
  place-items: center;
  padding: 16px;
}

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

.modal {
  width: 100%;
  max-width: 483px;
  background: #353535;
  border-radius: 24px;
  border: 1px solid #333333;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.modal-title {
  font-family: Rajdhani, system-ui, sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.modal-subtitle {
  margin-top: 6px;
  color: var(--subtext);
  font-size: 14px;
  line-height: 1.4;
}

.icon-btn {
  border: 0;
  background: transparent;
  padding: 4px;
  cursor: pointer;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  color: #fcfcfd;
}

.field-input {
  height: 48px;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}

.primary-btn {
  height: 40px;
  border-radius: 4px;
  border: 0;
  background: #ffffff;
  color: #1e1e1e;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.36px;
  cursor: pointer;
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-error {
  min-height: 16px;
  font-size: 12px;
  color: #ffb4b4;
}

@media (max-width: 640px) {
  .topbar {
    padding: 20px 16px 10px;
  }
  .bubble {
    padding: 14px 16px;
    font-size: 15px;
  }
}
