@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap");

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f7f8;
  --surface-user: #eceff3;
  --line: #d8dbe2;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2b4eff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface-soft: #1f1f1f;
  --surface-user: #1f1f1f;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f1f3f4;
  --muted: #9aa0a6;
  --accent: #2b4eff;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 16px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
}

.chat-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.chat-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px 6px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
}

.header-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.header-title {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.header-model-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
}

.header-model-name {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text);
}

.header-model-caret {
  color: var(--muted);
  font-size: 0.95rem;
  transform: translateY(-1px);
}

.header-journal-title {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.1;
}

.header-actions-pill {
  min-width: 96px;
  height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
}

.icon-lines,
.icon-plus,
.icon-mic,
.icon-send,
.icon-edit,
.icon-more {
  position: relative;
  display: inline-block;
}

.icon-lines {
  width: 18px;
  height: 12px;
}

.icon-lines::before,
.icon-lines::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.icon-lines::before {
  top: 1px;
  box-shadow: 0 5px 0 currentColor;
}

.icon-lines::after {
  top: 10px;
  width: 12px;
}

.icon-edit {
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 999px;
}

.icon-edit::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
  top: 8px;
  left: 3px;
  border-radius: 999px;
}

.icon-more {
  width: 16px;
  height: 4px;
}

.icon-more::before {
  content: "";
  position: absolute;
  inset: 0;
  background: currentColor;
  border-radius: 999px;
  box-shadow: -6px 0 0 currentColor, 6px 0 0 currentColor;
}

.icon-plus {
  width: 18px;
  height: 18px;
}

.icon-plus::before,
.icon-plus::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.icon-plus::before {
  width: 18px;
  height: 2px;
}

.icon-plus::after {
  width: 2px;
  height: 18px;
}

.icon-mic {
  width: 16px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.icon-mic::before,
.icon-mic::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: currentColor;
}

.icon-mic::before {
  bottom: -6px;
  width: 2px;
  height: 8px;
}

.icon-mic::after {
  bottom: -8px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
}

.icon-send {
  width: 18px;
  height: 18px;
}

.icon-send::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 8px;
  height: 8px;
  border-top: 2.5px solid #0b0f19;
  border-right: 2.5px solid #0b0f19;
  transform: rotate(45deg);
}

.icon-send::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 8px;
  width: 11px;
  height: 2.5px;
  background: #0b0f19;
  border-radius: 999px;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 4px 18px 136px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.message {
  width: 100%;
  display: flex;
  justify-content: center;
}

.message-inner {
  width: min(100%, 760px);
}

.message-role {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.message-content {
  line-height: 1.56;
  font-size: 1.04rem;
}

.message.user .message-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding-top: 8px;
}

.message.user .message-content {
  max-width: min(100%, 520px);
  background: var(--surface-user);
  border-radius: 28px;
  padding: 16px 18px;
}

.message.assistant .message-inner {
  padding: 10px 4px 16px;
}

.message-content p,
.message-content ul,
.message-content ol {
  margin: 0 0 18px;
}

.message-content p:last-child,
.message-content ul:last-child,
.message-content ol:last-child {
  margin-bottom: 0;
}

.message-content ul,
.message-content ol {
  padding-left: 28px;
}

.message-content li {
  margin: 0 0 10px;
}

.message-content strong {
  font-weight: 700;
}

.message-content .lead-line {
  font-weight: 600;
}

.empty-state {
  flex: 1 1 auto;
  display: grid;
  place-items: center;
  min-height: 52vh;
}

.empty-state-inner {
  width: min(100%, 520px);
  text-align: center;
}

.empty-kicker {
  margin: 0 0 8px;
  font-size: 1.02rem;
  font-weight: 500;
  background: linear-gradient(90deg, #6ea8fe 0%, #9b72cb 45%, #d96570 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.empty-state h2 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 3.5rem);
  line-height: 1.08;
  font-weight: 400;
  letter-spacing: 0;
  color: color-mix(in srgb, var(--text) 92%, white 8%);
}

.attachment-row {
  width: min(100%, 760px);
  margin: 0 auto 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.attachment-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 0.94rem;
  color: var(--muted);
}

.attachment-pill button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
  padding: 12px 18px 18px;
  background: linear-gradient(to top, var(--surface) 76%, color-mix(in srgb, var(--surface) 40%, transparent));
}

.prompt-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--surface-soft);
  padding: 16px 16px 10px;
}

.composer textarea {
  width: 100%;
  min-height: 28px;
  max-height: 220px;
  resize: none;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  line-height: 1.5;
  outline: none;
  box-shadow: none;
  font-size: 1.1rem;
}

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

.actions {
  width: 100%;
  margin: 8px auto 0;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 500;
}

.button:hover {
  background: color-mix(in srgb, var(--surface-soft) 86%, var(--line));
}

.button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.button-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--line);
}

.button-file {
  position: relative;
  overflow: hidden;
}

.button-file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.icon-button,
.send-button {
  border: 0;
  border-radius: 999px;
  min-width: 44px;
  height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  background: color-mix(in srgb, var(--surface) 80%, var(--line));
  color: var(--text);
}

.send-button {
  background: var(--accent);
  min-width: 52px;
  padding: 0 15px;
}

.send-button:hover {
  background: color-mix(in srgb, var(--accent) 86%, white 14%);
}

#dictationButton[data-listening="true"] {
  background: rgba(138, 180, 248, 0.16);
  color: var(--accent);
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
  opacity: 0.4;
  animation: geminiDots 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes geminiDots {
  0%,
  80%,
  100% {
    transform: scale(0.9);
    opacity: 0.35;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.settings-drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
}

.settings-summary {
  display: none;
}

.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 160ms ease;
}

.settings-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(100%);
  width: min(100%, 760px);
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  background: #171717;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-bottom: 0;
  padding: 0 18px 28px;
  display: grid;
  gap: 18px;
  transition: transform 180ms ease;
}

.settings-drawer[open] {
  pointer-events: auto;
}

.settings-drawer[open] .settings-backdrop {
  opacity: 1;
}

.settings-drawer[open] .settings-panel {
  transform: translateX(-50%) translateY(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 2px 2px;
}

.settings-header h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 500;
}

.settings-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.field,
.field-grid {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 0.98rem;
}

.field-grid fieldset,
.field-grid-compact {
  max-width: 180px;
}

.settings-panel select,
.settings-panel input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  padding: 16px 18px;
  color: var(--text);
  font-size: 1.05rem;
  box-shadow: inset 0 0 0 1px rgba(138, 180, 248, 0.04);
}

.settings-panel .actions {
  margin-top: 2px;
  justify-content: flex-start;
}

.settings-panel .button {
  min-height: 46px;
  padding: 12px 18px;
  border-radius: 18px;
}

@media (max-width: 720px) {
  .chat-header {
    padding: 14px 14px 6px;
  }

  .header-model-name {
    font-size: 1rem;
  }

  .header-journal-title {
    font-size: 0.82rem;
  }

  .messages {
    padding: 4px 14px 124px;
  }

  .message-content {
    font-size: 1.03rem;
  }

  .prompt-shell {
    padding: 14px 14px 10px;
  }

  .header-actions-pill {
    min-width: 92px;
    padding: 0 14px;
  }

  .settings-panel {
    width: 100%;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 0 14px 24px;
  }
}
