:root {
  --accent: #17a897;
  --accent-ink: #073b35;
  --ink: #17211f;
  --muted: rgba(23, 33, 31, 0.66);
  --line: rgba(255, 255, 255, 0.36);
  --panel-alpha: 0.68;
  --bg-image: url("./background.svg");
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #1d2824 var(--bg-image) center / cover fixed no-repeat;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 18, 18, 0.18);
}

.phone-shell {
  width: min(430px, 100%);
  height: min(880px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 30px;
  background: rgba(246, 251, 247, var(--panel-alpha));
  box-shadow: 0 24px 80px rgba(4, 18, 18, 0.34);
  backdrop-filter: blur(22px) saturate(1.18);
}

.top-bar {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 18px 0;
  color: rgba(12, 27, 25, 0.78);
  font-size: 13px;
  font-weight: 650;
}

.server-status {
  max-width: 56%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.36);
  color: rgba(12, 27, 25, 0.68);
}

.server-status.online {
  color: #0e665b;
}

.server-status.offline {
  color: #9d2838;
}

.screen {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  min-height: 0;
}

.view-active {
  display: flex;
}

#chatView {
  flex-direction: column;
  padding: 14px 16px 12px;
}

.chat-header,
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 14px;
}

.settings-header {
  display: block;
  padding: 18px 20px 8px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.05;
  letter-spacing: 0;
}

.icon-button,
.send-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.icon-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.42);
}

.send-button {
  color: white;
  background: var(--accent);
  box-shadow: 0 10px 22px rgba(10, 89, 81, 0.26);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.48;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 4px 14px;
  scroll-behavior: smooth;
}

.empty-state {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  color: rgba(23, 33, 31, 0.62);
  text-align: center;
  font-size: 18px;
  line-height: 1.45;
}

.message {
  display: flex;
  margin: 14px 0;
}

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

.message.assistant {
  justify-content: flex-start;
}

.message-content {
  max-width: min(84%, 34ch);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.62;
  font-size: 15px;
}

.message.user .message-content {
  padding: 10px 13px;
  color: white;
  background: linear-gradient(135deg, var(--accent), #2670a9);
  border-radius: 18px 18px 5px 18px;
  box-shadow: 0 10px 24px rgba(12, 80, 86, 0.2);
}

.message.assistant .message-content {
  color: rgba(17, 28, 27, 0.94);
}

.message.assistant.pending .message-content::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 3px;
  vertical-align: -0.15em;
  border-radius: 2px;
  background: var(--accent);
  animation: blink 0.9s infinite;
}

@keyframes blink {
  0%,
  52% {
    opacity: 0.22;
  }
  53%,
  100% {
    opacity: 1;
  }
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(18px);
}

.composer textarea {
  width: 100%;
  max-height: 140px;
  resize: none;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  line-height: 1.5;
  padding: 9px 4px 9px 8px;
}

.composer textarea::placeholder {
  color: rgba(23, 33, 31, 0.46);
}

#settingsView {
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 12px;
}

.settings-list {
  display: grid;
  gap: 12px;
  padding: 8px 16px 20px;
}

.field {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.44);
}

.field span {
  color: rgba(23, 33, 31, 0.72);
  font-size: 13px;
  font-weight: 700;
}

.field input:not([type="range"]):not([type="color"]),
.field textarea {
  width: 100%;
  border: 0;
  outline: 0;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.66);
  padding: 11px 12px;
}

.field textarea {
  resize: vertical;
  line-height: 1.5;
}

.field input[type="color"] {
  width: 52px;
  height: 38px;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  align-items: center;
  gap: 12px;
}

input[type="range"] {
  accent-color: var(--accent);
}

output {
  color: rgba(23, 33, 31, 0.66);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 700;
}

.primary-button {
  color: white;
  background: var(--accent);
}

.secondary-button {
  color: var(--accent-ink);
  background: rgba(255, 255, 255, 0.48);
  border-color: rgba(255, 255, 255, 0.38);
}

.bottom-tabs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 10px 16px max(14px, env(safe-area-inset-bottom));
  background: rgba(246, 251, 247, calc(var(--panel-alpha) + 0.1));
  border-top: 1px solid rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(20px);
}

.tab-button {
  height: 50px;
  display: grid;
  grid-template-columns: auto auto;
  place-content: center;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  color: rgba(23, 33, 31, 0.56);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.tab-button svg {
  width: 19px;
  height: 19px;
}

.tab-active {
  color: var(--accent-ink);
  background: rgba(255, 255, 255, 0.52);
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0;
  }

  .phone-shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
}
