:root {
  color-scheme: light;
  --bg: #eef3f0;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --text: #14201a;
  --muted: #6e7c74;
  --line: #dbe5df;
  --accent: #2fbf71;
  --accent-2: #e4f8ee;
  --info: #2f7fa0;
  --danger: #d94d42;
  --danger-bg: #fff0ee;
  --shadow: 0 18px 48px rgba(42, 66, 52, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
}

button,
.button,
input {
  font: inherit;
}

button,
.button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
.button.disabled {
  opacity: 0.52;
}

button:active,
.button:active {
  transform: translateY(1px);
}

input {
  min-width: 0;
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 13px;
  -webkit-user-select: text;
  user-select: text;
}

h1,
h2,
p {
  margin: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-box {
  width: min(100%, 360px);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-box h1 {
  font-size: 32px;
  line-height: 1.05;
}

.login-box p {
  color: var(--muted);
  line-height: 1.35;
}

.login-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 14px;
}

.login-screen.hidden,
.hidden {
  display: none;
}

.app {
  width: min(100%, 720px);
  height: 100dvh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  gap: 12px;
  overflow: hidden;
}

.topbar {
  min-height: 72px;
  max-height: 72px;
  padding: 2px 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  min-width: 0;
}

.brand h1 {
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.brand p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
  max-width: 430px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.state-pill {
  width: 88px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #a7b5ad;
}

.dot.active {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(47, 191, 113, 0.16);
}

.controls {
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  gap: 10px;
}

.mic-button {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 16px 42px rgba(47, 191, 113, 0.32);
}

.mic-button span {
  font-size: 38px;
}

.tool-row {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.icon-button {
  width: 100%;
  height: 52px;
  padding: 0;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 28px rgba(42, 66, 52, 0.08);
}

.icon-button span {
  font-size: 22px;
}

.danger {
  background: var(--danger-bg);
  border-color: #f2c9c5;
  color: var(--danger);
}

.file-button input {
  display: none;
}

.answer,
.camera-panel,
.memory {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.camera-panel {
  padding: 10px;
  overflow: hidden;
}

.camera-panel video {
  width: 100%;
  max-height: 30dvh;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 8px;
  background: #edf2ef;
}

.camera-actions,
.memory-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 8px;
}

.camera-actions button,
.memory-search button {
  min-height: 48px;
  padding: 0 13px;
}

.answer {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
}

.answer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 13px 0;
}

.answer-head h2 {
  font-size: 17px;
  letter-spacing: 0;
}

#hintText {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#speakBtn {
  width: 42px;
  min-height: 38px;
  border-radius: 8px;
}

.transcript {
  min-height: 30px;
  padding: 8px 13px 0;
  color: var(--info);
  font-size: 14px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
}

#answerBox {
  min-height: 0;
  padding: 10px 13px 14px;
  color: var(--text);
  line-height: 1.48;
  white-space: pre-wrap;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: text;
  user-select: text;
}

.memory {
  padding: 12px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.memory-item {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.memory-item:first-child {
  border-top: 0;
}

.memory-kind {
  color: var(--info);
  font-size: 13px;
}

@media (max-width: 430px) {
  .app {
    gap: 10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .mic-button {
    width: 90px;
    height: 90px;
  }

  .icon-button {
    height: 50px;
  }
}

@media (max-width: 340px) {
  .brand h1 {
    font-size: 30px;
  }

  .brand p,
  .transcript {
    font-size: 13px;
  }

  .tool-row {
    gap: 6px;
  }
}
