/* Shared theme tokens/reset/base elements for all webapp pages.
   Light is the default palette; data-theme="dark" (see static/theme.js) swaps it. */

:root {
  color-scheme: light;
  --bg: #f6efe0;
  --panel: #fffcf5;
  --border: #ddceac;
  --text: #241f16;
  --muted: #5f5340;
  --accent: #1f6b45;
  --accent-hover: #17512f;
  --nav-hover: #b8863a;
  --ok: #1f9d63;
  --err: #b8452f;
  --content-max: 760px;
  --shadow-sm: 0 1px 2px rgba(36, 31, 22, 0.06);
  --shadow-md: 0 2px 8px rgba(36, 31, 22, 0.09);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17130f;
  --panel: #211c15;
  --border: #3a3225;
  --text: #f1e9d8;
  --muted: #a89a7c;
  --accent: #3fae7a;
  --accent-hover: #56c491;
  --nav-hover: #d9ab5c;
  --ok: #3ecf8e;
  --err: #e37257;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 1.4rem; margin: 0 0 0.25rem; }
.subtitle { color: var(--muted); margin: 0 0 1.75rem; font-size: 0.92rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
}
input[type=text], input[type=date], input[type=url], input[type=file],
select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--accent-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
/* Send/Search button toggled into a Stop control while a chat/search request is
   in flight -- reuses the existing --err token so it reads as a distinct action
   from the accent-colored default, in both themes. */
.stop-mode { background: var(--err); }
.stop-mode:hover:not(:disabled) { background: var(--err); filter: brightness(0.9); }
.secondary-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
}

/* Header bar reused by every page: full-width nav bar, site name on the
   left, action buttons grouped and right-aligned. */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 2.25rem;
  margin: 0 0 1.5rem;
  position: relative;
  z-index: 1;
}
.site-header a.site-name {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.45rem;
}
.site-header a.site-name:hover { color: var(--nav-hover); }
.site-header .nav-btn {
  display: inline-block;
  text-decoration: none;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  padding: 0.7rem 1.35rem;
  font-size: 1.02rem;
  font-weight: 600;
}
.site-header .nav-btn.nav-btn-unique { background: var(--ok); }
.site-header .nav-btn:hover { background: var(--nav-hover); }
.header-actions { display: flex; align-items: center; gap: 1.1rem; }
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}
.theme-toggle-btn:hover { border-color: var(--nav-hover); color: var(--nav-hover); }
.lang-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: auto;
  height: 2.6rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0 0.7rem;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
}
.lang-toggle-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.settings-toggle-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  width: 2.6rem;
  height: 2.6rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
}
.settings-toggle-btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Legal-advice disclaimer, shown near the primary action area on chat.html and search.html. */
.disclaimer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
  margin-top: 0.6rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  border-radius: 8px;
}

/* Shared page footer bar, mirroring .site-header: full-width, same panel
   background/border, centered copyright text. margin-top: auto (inside
   body's flex column) pins it to the bottom of the viewport even on short
   pages, instead of riding up under sparse content. */
.site-footer {
  width: 100%;
  flex-shrink: 0;
  margin-top: auto;
  padding: 0.9rem 2.25rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer-copyright { color: var(--muted); font-size: 0.8rem; margin: 0; text-align: center; }

/* Disclosure sections (<details>/<summary>) get button-like chip styling
   instead of the bare browser triangle marker. */
details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
}
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "▸"; color: var(--muted); }
details[open] summary::after { content: "▾"; }
details summary:hover { border-color: var(--accent); color: var(--accent); }

/* Subtle decorative diamond-lattice motif, anchored to each viewport corner
   and faded toward the center. Purely presentational — sits behind content. */
.corner-pattern {
  position: fixed;
  width: 260px;
  height: 260px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 0L40 20L20 40L0 20Z' fill='none' stroke='%23c9b88a' stroke-width='1.4'/%3E%3C/svg%3E");
  background-size: 40px 40px;
}
:root[data-theme="dark"] .corner-pattern {
  opacity: 0.16;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M20 0L40 20L20 40L0 20Z' fill='none' stroke='%234a4030' stroke-width='1.4'/%3E%3C/svg%3E");
}
.corner-pattern.tl {
  top: 0; left: 0;
  -webkit-mask-image: radial-gradient(circle at top left, black 0%, transparent 72%);
  mask-image: radial-gradient(circle at top left, black 0%, transparent 72%);
}
.corner-pattern.tr {
  top: 0; right: 0;
  -webkit-mask-image: radial-gradient(circle at top right, black 0%, transparent 72%);
  mask-image: radial-gradient(circle at top right, black 0%, transparent 72%);
}
.corner-pattern.bl {
  bottom: 0; left: 0;
  -webkit-mask-image: radial-gradient(circle at bottom left, black 0%, transparent 72%);
  mask-image: radial-gradient(circle at bottom left, black 0%, transparent 72%);
}
.corner-pattern.br {
  bottom: 0; right: 0;
  -webkit-mask-image: radial-gradient(circle at bottom right, black 0%, transparent 72%);
  mask-image: radial-gradient(circle at bottom right, black 0%, transparent 72%);
}
