:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  --bg: #d9c4a5;
  --surface: #b6a98f;
  --surface-soft: #ac9a81;
  --text: #464239;
  --text-muted: #7c7360;
  --accent: #bd4756;
  --accent-hover: #a33a49;
  --border: #7c7360;
  --container-max: 900px;
  --container-pad: 16px;
  --sidebar-width: 200px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  padding: 16px 12px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(172, 154, 129, 0.35);
  border-right: 1px solid rgba(124, 115, 96, 0.35);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 10px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link:hover {
  background: rgba(70, 66, 57, 0.08);
}

.sidebar-link.is-active {
  color: var(--accent);
  background: rgba(189, 71, 86, 0.14);
}

.sidebar-art {
  width: 100px;
  height: auto;
  display: block;
  align-self: flex-start;
  opacity: 0.92;
}

.layout-main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 767px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid rgba(124, 115, 96, 0.35);
    gap: 12px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-art {
    display: none;
  }
}

.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtitle {
  margin-top: 8px;
  color: var(--text-muted);
}

.recommendation-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(70, 66, 57, 0.14);
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

.card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 24px rgba(70, 66, 57, 0.18);
  border: 1px solid rgba(124, 115, 96, 0.35);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  resize: vertical;
  font: inherit;
  background: #efe3d0;
  color: var(--text);
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(189, 71, 86, 0.28);
}

button {
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.status {
  min-height: 22px;
  margin-top: 10px;
  color: var(--text-muted);
}

.answer-body {
  white-space: normal;
}

.answer-body:not(.empty) {
  line-height: 1.55;
}

.answer-body:not(.empty) p {
  margin: 0.55em 0;
}

.answer-body:not(.empty) p:first-child {
  margin-top: 0;
}

.answer-body:not(.empty) p:last-child {
  margin-bottom: 0;
}

.answer-body:not(.empty) h1,
.answer-body:not(.empty) h2,
.answer-body:not(.empty) h3,
.answer-body:not(.empty) h4 {
  margin: 0.9em 0 0.45em;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
}

.answer-body:not(.empty) h1:first-child,
.answer-body:not(.empty) h2:first-child,
.answer-body:not(.empty) h3:first-child {
  margin-top: 0;
}

.answer-body:not(.empty) ul,
.answer-body:not(.empty) ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
}

.answer-body:not(.empty) li {
  margin: 0.2em 0;
}

.answer-body:not(.empty) blockquote {
  margin: 0.6em 0;
  padding: 0.35em 0 0.35em 0.85em;
  border-left: 3px solid rgba(124, 115, 96, 0.55);
  color: var(--text-muted);
}

.answer-body:not(.empty) code {
  font-size: 0.92em;
  background: rgba(70, 66, 57, 0.1);
  padding: 0.12em 0.35em;
  border-radius: 5px;
}

.answer-body:not(.empty) pre {
  margin: 0.6em 0;
  padding: 10px 12px;
  overflow-x: auto;
  background: rgba(70, 66, 57, 0.08);
  border-radius: 8px;
  font-size: 0.9em;
}

.answer-body:not(.empty) pre code {
  background: none;
  padding: 0;
}

.answer-body:not(.empty) a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.answer-body:not(.empty) strong {
  font-weight: 700;
}

.empty {
  color: var(--text-muted);
}

.history {
  display: grid;
  gap: 10px;
}

.history-item {
  border: 1px solid rgba(124, 115, 96, 0.45);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface-soft);
}

.history-item p {
  margin: 4px 0;
}

.history-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.history-teas-wrap {
  margin: 6px 0 4px;
}

.history-teas-label {
  display: block;
  margin-bottom: 6px;
}

.history-tea-list {
  margin: 0;
  padding-left: 1.2em;
}

.history-tea-list li {
  margin: 2px 0;
}

.history-teas-plain {
  margin: 4px 0 0;
}

.catalog-search-form label {
  margin-bottom: 8px;
}

.catalog-search-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.catalog-search-row input[type="search"] {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  background: #efe3d0;
  color: var(--text);
}

.catalog-search-row input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(189, 71, 86, 0.28);
}

.catalog-search-row button {
  margin-top: 0;
}

.catalog-section-title {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.catalog-msg {
  margin: 0;
  color: var(--text-muted);
}

.catalog-msg code {
  font-size: 0.88em;
  word-break: break-all;
}

.sort-link-list,
.tea-link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.sort-link-list li,
.tea-link-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid rgba(124, 115, 96, 0.35);
}

.sort-link-list a,
.tea-link-list a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.sort-link-list a:hover,
.tea-link-list a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sort-count,
.tea-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.breadcrumb {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.tea-detail-header .subtitle {
  margin-top: 4px;
}

.tea-detail .tea-figure {
  margin: 0 0 16px;
}

.tea-photo {
  display: block;
  max-width: min(420px, 100%);
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(124, 115, 96, 0.4);
  box-shadow: 0 6px 16px rgba(70, 66, 57, 0.15);
}

.tea-block h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.tea-block p {
  margin: 0;
  white-space: pre-wrap;
}

.tea-block + .tea-block {
  margin-top: 18px;
}

@media (min-width: 768px) {
  :root {
    --container-pad: 28px;
  }

  .container {
    padding: 28px;
  }

  .header h1 {
    font-size: 2.2rem;
  }

  .card {
    padding: 20px;
  }
}
