* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #fafafa;
  color: #1c1c1e;
  -webkit-tap-highlight-color: transparent;
}

.page {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

.bento-card {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #e5e5ea;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.header {
  display: flex;
  gap: 12px;
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.header-main {
  flex: 1;
  padding: 14px 16px;
}

.header-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.header-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: #8e8e93;
}

.lang-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #f2f2f7;
}

.lang-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lang-label {
  font-size: 12px;
  color: #8e8e93;
}

.lang-select {
  border: none;
  background: #f2f2f7;
  color: #007aff;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 10px;
  max-width: 62%;
}

.stats {
  width: 72px;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stats-num {
  font-size: 22px;
  font-weight: 700;
  color: #007aff;
  line-height: 1;
}

.stats-label {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 4px;
}

.fav-hint {
  margin: 0 12px 8px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #3a3a3c;
  position: relative;
}

.fav-hint-close {
  position: absolute;
  top: 4px;
  right: 8px;
  border: none;
  background: none;
  font-size: 20px;
  color: #8e8e93;
  cursor: pointer;
  padding: 4px 8px;
}

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  -webkit-overflow-scrolling: touch;
}

.message-row {
  display: flex;
  margin-bottom: 10px;
}

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

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  word-break: break-word;
}

.bubble--user {
  background: #007aff;
  color: #fff;
  border-bottom-right-radius: 6px;
}

.bubble--assistant {
  background: #fff;
  border: 1px solid #e5e5ea;
  border-bottom-left-radius: 6px;
}

.bubble-label {
  display: block;
  font-size: 11px;
  color: #8e8e93;
  margin-bottom: 4px;
  font-weight: 600;
}

.bubble-source {
  display: block;
  font-size: 12px;
  color: #8e8e93;
  margin-bottom: 6px;
}

.bubble-roman {
  display: block;
  font-size: 13px;
  color: #636366;
  margin-top: 6px;
}

.bubble--loading .bubble-text {
  color: #8e8e93;
}

.copy-btn {
  margin-top: 8px;
  padding: 6px 12px;
  font-size: 13px;
  color: #007aff;
  background: #f2f2f7;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.hints {
  flex-shrink: 0;
  padding: 8px 12px 4px;
}

.hints-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: #8e8e93;
  margin-bottom: 8px;
}

.hints-toggle {
  border: none;
  background: none;
  color: #007aff;
  font-size: 12px;
  cursor: pointer;
}

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

.chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 8px;
  border-radius: 14px;
  border: 1px solid #e5e5ea;
  background: #fff;
  cursor: pointer;
}

.chip--incoming {
  border-color: #34c759;
  background: #f0fff4;
}

.chip--outgoing {
  border-color: #007aff;
  background: #f0f7ff;
}

.chip-label {
  font-size: 16px;
  font-weight: 700;
}

.chip-hint {
  font-size: 11px;
  color: #8e8e93;
  margin-top: 2px;
}

.hints-collapsed {
  flex-shrink: 0;
  margin: 4px 12px;
  padding: 8px;
  text-align: center;
  font-size: 13px;
  color: #007aff;
  background: none;
  border: none;
  cursor: pointer;
}

.input-bar {
  flex-shrink: 0;
  padding: 8px 12px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.input-card {
  display: flex;
  align-items: center;
  padding: 6px 6px 6px 14px;
  gap: 8px;
}

.input-field {
  flex: 1;
  border: none;
  font-size: 16px;
  outline: none;
  background: transparent;
  min-width: 0;
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: #007aff;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.legal-links {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 4px 12px 0;
  font-size: 11px;
  color: #8e8e93;
}

.legal-links a {
  color: #007aff;
  text-decoration: none;
}

.legal-dot {
  color: #c7c7cc;
}

.legal-copy {
  color: #aeaeb2;
}

.copy-btn--done {
  color: #34c759;
  background: #e8f9ee;
}

.copy-hint {
  display: none;
}

.legal-body {
  background: #fafafa;
  min-height: 100%;
}

.legal-page {
  max-width: 640px;
  margin: 16px auto;
  padding: 20px 18px 28px;
  line-height: 1.55;
  font-size: 14px;
  color: #1c1c1e;
}

.legal-page h1 {
  margin: 12px 0 8px;
  font-size: 22px;
}

.legal-page h2 {
  margin: 20px 0 8px;
  font-size: 16px;
}

.legal-page p,
.legal-page ul {
  margin: 8px 0;
}

.legal-page ul {
  padding-left: 20px;
}

.legal-meta {
  font-size: 13px;
  color: #8e8e93;
}

.legal-back {
  display: inline-block;
  color: #007aff;
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 8px;
}

.legal-footer-note {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #e5e5ea;
  font-size: 12px;
  color: #8e8e93;
}

.legal-footer-note a {
  color: #007aff;
}
