@import url("https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Space+Grotesk:wght@400;600&display=swap");

:root {
  /* deploy bump */
  color-scheme: light;
  --bg: #f7f3ec;
  --ink: #1c1b18;
  --muted: #6c665e;
  --soft: #fefbf6;
  --accent: #d16a4f;
  --accent-2: #2d5f7a;
  --stroke: rgba(28, 27, 24, 0.12);
  --shadow: 0 24px 60px rgba(28, 27, 24, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Noto Serif SC", "Noto Serif", serif;
  color: var(--ink);
  background: radial-gradient(
      1200px 600px at 12% -10%,
      rgba(243, 221, 196, 0.75),
      transparent 60%
    ),
    radial-gradient(
      900px 500px at 90% 10%,
      rgba(198, 221, 233, 0.65),
      transparent 55%
    ),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(28, 27, 24, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(28, 27, 24, 0.04) 1px,
      transparent 1px
    );
  background-size: 48px 48px;
  opacity: 0.25;
  pointer-events: none;
}

header,
main,
footer {
  position: relative;
  z-index: 1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 32px clamp(20px, 4vw, 64px);
  animation: rise 0.8s ease both;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  --logo-size: 44px;
  --logo-gap: 6px;
}

.brand-top {
  display: flex;
  align-items: center;
  gap: var(--logo-gap);
}

.brand img {
  width: var(--logo-size);
  height: var(--logo-size);
}

.brand h1 {
  margin: 0;
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  font-size: clamp(20px, 2.6vw, 28px);
  letter-spacing: 0.02em;
  line-height: 1;
}

.brand-sub {
  margin-left: calc(var(--logo-size) + var(--logo-gap));
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand p {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  font-size: 14px;
  line-height: 1.1;
}

.text-btn {
  border: none;
  background: transparent;
  padding: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.1;
}

.text-btn:hover {
  opacity: 0.7;
}

.text-link {
  font-size: 14px;
  line-height: 1.1;
  color: var(--muted);
}

.user-badge {
  font-size: 12px;
  color: var(--muted);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 16px clamp(20px, 4vw, 64px) 48px;
  text-align: left;
  animation: rise 0.9s ease both;
  animation-delay: 0.1s;
  min-height: 0;
}

body[data-page="home"] main {
  justify-content: center;
  text-align: center;
}

.hero {
  width: min(760px, 100%);
  padding: clamp(12px, 3vw, 24px);
}

.page {
  width: min(860px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.page-header {
  margin-bottom: 6px;
}

.page-header h2 {
  margin: 0 0 6px;
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--ink);
}

.page-sub {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.page-title-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.page-title-block h1,
.page-title-block h2 {
  margin: 0;
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  font-size: clamp(18px, 2.2vw, 22px);
  color: var(--ink);
}

.input-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  flex-wrap: nowrap;
  width: 100%;
}

.input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.input-wrap input {
  width: 100%;
  padding: 18px 56px 18px 22px;
  font-size: 18px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: white;
  font-family: "Noto Serif SC", "Noto Serif", serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrap input:focus {
  outline: none;
  border-color: rgba(209, 106, 79, 0.65);
  box-shadow: 0 0 0 4px rgba(209, 106, 79, 0.15);
}

.plus-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px dashed rgba(28, 27, 24, 0.2);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  background: transparent;
}

.submit-btn {
  border: none;
  background: var(--accent);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 22px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 12px 24px rgba(209, 106, 79, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(209, 106, 79, 0.35);
}

.submit-btn:disabled,
.plus-icon:disabled,
.text-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.helper {
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.chat-panel {
  flex: 1;
  min-height: 0;
}

.chat-card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(28, 27, 24, 0.08);
  border-radius: 18px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  text-align: left;
}

.chat-message {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 80%;
  font-size: 14px;
}

.chat-message.user {
  align-self: flex-end;
  background: rgba(209, 106, 79, 0.15);
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.75);
}

.chat-message.assistant p {
  margin: 0 0 8px;
}

.chat-message.assistant p:last-child {
  margin-bottom: 0;
}

.chat-message.assistant ul,
.chat-message.assistant ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.chat-message.assistant li {
  margin-bottom: 4px;
}

.chat-message.assistant code {
  background: rgba(28, 27, 24, 0.08);
  padding: 2px 6px;
  border-radius: 6px;
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  font-size: 0.92em;
}

.chat-message.assistant pre {
  background: rgba(28, 27, 24, 0.08);
  padding: 10px 12px;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.92em;
}

.chat-message.assistant pre code {
  background: transparent;
  padding: 0;
}

.chat-references {
  margin-top: 10px;
  border-top: 1px solid rgba(28, 27, 24, 0.08);
  padding-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.chat-references-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.chat-references-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
}

.chat-references-list a {
  color: var(--accent-2);
  text-decoration: none;
}

.chat-references-list a:hover {
  text-decoration: underline;
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-input input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  padding: 14px 18px;
  background: #fff;
  font-family: "Noto Serif SC", "Noto Serif", serif;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  justify-content: space-between;
}

.record-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.record-item {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(28, 27, 24, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
}

.record-item small {
  display: block;
  color: var(--muted);
  margin-top: 6px;
  font-size: 12px;
}

.record-item .record-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent-2);
  text-decoration: none;
  font-size: 12px;
}

.record-item .record-link:hover {
  text-decoration: underline;
}

footer {
  padding: 22px clamp(20px, 4vw, 64px) 32px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  animation: rise 0.9s ease both;
  animation-delay: 0.2s;
}

.footer-minimal {
  padding: 18px clamp(20px, 4vw, 64px) 26px;
}

.footer-text {
  display: grid;
  gap: 4px;
}

.footer-text p {
  margin: 0;
}

.footer-meta {
  font-size: 12px;
}

.footer-actions {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

body[data-page="chat"],
body[data-page="chat-list"],
body[data-page="records"] {
  height: 100vh;
  overflow: hidden;
}

body[data-page="chat"] main,
body[data-page="chat-list"] main,
body[data-page="records"] main {
  overflow: hidden;
}

body[data-page="chat"] .page,
body[data-page="chat-list"] .page,
body[data-page="records"] .page {
  flex: 1;
}

body[data-page="chat"] .chat-panel,
body[data-page="chat-list"] .list-panel,
body[data-page="records"] .list-panel {
  flex: 1;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.25);
  padding: 16px;
  z-index: 20;
}

.modal-card {
  max-width: 520px;
  width: 100%;
  background: #fff;
  border-radius: 18px;
  padding: 20px;
  border: 1px solid rgba(28, 27, 24, 0.1);
  text-align: left;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.modal-actions .submit-btn {
  width: auto;
  height: auto;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  box-shadow: 0 12px 24px rgba(209, 106, 79, 0.25);
}

.hidden {
  display: none;
}

.legal {
  width: 100%;
  max-width: 860px;
  padding: 12px 0 32px;
  margin: 0;
  text-align: left;
  color: var(--ink);
}

.legal h1,
.legal h2 {
  font-family: "Space Grotesk", "Noto Serif SC", serif;
  color: var(--ink);
}

.legal h1 {
  font-size: clamp(22px, 2.6vw, 30px);
  margin-bottom: 12px;
}

.legal h2 {
  font-size: 18px;
  margin-top: 26px;
  margin-bottom: 8px;
}

.legal p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
}

.legal ul {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.7;
}

.legal-en {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.legal h2 .legal-en {
  display: block;
  font-weight: 400;
}

.legal-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 18px;
}

body[data-page="legal"] {
  height: 100vh;
  overflow: hidden;
}

body[data-page="legal"] main {
  align-items: center;
  overflow: hidden;
  padding-bottom: 0;
}

body[data-page="legal"] .legal {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 680px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-end;
  }

  body[data-page="legal"] header {
    flex-direction: row;
    align-items: flex-start;
  }

  body[data-page="legal"] .top-actions {
    width: auto;
  }

  .input-shell {
    gap: 8px;
  }

  .input-wrap input {
    padding: 16px 46px 16px 18px;
    font-size: 16px;
  }

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

  .submit-btn {
    width: 44px;
    height: 44px;
    font-size: 20px;
  }

  main {
    padding: 8px 16px 20px;
  }

  .page {
    gap: 10px;
  }

  .chat-card {
    padding: 12px;
  }

  .chat-thread {
    margin-bottom: 10px;
  }

  body[data-page="chat"] header,
  body[data-page="chat-list"] header,
  body[data-page="records"] header,
  body[data-page="legal"] header {
    padding: 18px 16px 10px;
  }

  body[data-page="chat"] main,
  body[data-page="chat-list"] main,
  body[data-page="records"] main,
  body[data-page="legal"] main {
    padding-top: 6px;
    padding-bottom: 16px;
  }

  .legal {
    padding-top: 8px;
  }

  footer {
    padding: 14px 16px 20px;
    flex-direction: column;
    align-items: flex-start;
  }

  .footer-minimal {
    padding: 12px 16px 18px;
  }

  .footer-actions {
    order: -1;
    width: 100%;
    justify-content: flex-end;
  }

  body[data-page="chat"] header,
  body[data-page="chat-list"] header,
  body[data-page="records"] header {
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
  }

  body[data-page="chat"] .top-actions,
  body[data-page="chat-list"] .top-actions,
  body[data-page="records"] .top-actions {
    width: auto;
    justify-content: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
