:root {
  --bg: #f5f1eb;
  --surface: rgba(255, 251, 245, 0.94);
  --surface-strong: #fffdfa;
  --border: #d8cfc4;
  --text: #2a2118;
  --muted: #6b5d4f;
  --accent: #a74d1b;
  --accent-strong: #8a3d12;
  --danger: #b42318;
  --success: #165b33;
  --shadow: 0 8px 24px rgba(42, 33, 24, 0.06);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(167, 77, 27, 0.08), transparent 28%),
    linear-gradient(180deg, #f7f3ee 0%, #efe7dd 100%);
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-shell {
  min-height: 100vh;
}

.topbar {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-block h1,
.login-header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.brand-block p,
.login-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-summary {
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 253, 250, 0.82);
  color: var(--muted);
  font-size: 14px;
}

.layout {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.sidebar-panel {
  padding: 20px;
  align-self: start;
}

.workspace {
  display: grid;
  gap: 24px;
}

.result-panel,
.history-panel {
  padding: 20px;
}

.section-block + .section-block {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(216, 207, 196, 0.75);
}

.section-block h2,
.result-header h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 600;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form-stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 14px;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #c9bcaf;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.field textarea {
  resize: vertical;
  min-height: 180px;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 77, 27, 0.12);
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 16px;
}

.primary-button {
  background: var(--accent);
  color: #fff8f3;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ghost-button {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.ghost-button:hover {
  background: rgba(255, 253, 250, 0.9);
}

.hint-text,
.meta-text,
.history-meta,
.message,
.inline-link {
  font-size: 14px;
  color: var(--muted);
}

.message {
  min-height: 20px;
  margin: 0;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.key-value-list {
  margin: 0;
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 8px 12px;
  font-size: 14px;
}

.key-value-list dt {
  color: var(--muted);
}

.key-value-list dd {
  margin: 0;
}

.latest-card {
  display: grid;
  gap: 16px;
}

.latest-card img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #efe7dd;
}

.prompt-text,
.history-prompt {
  margin: 0;
  line-height: 1.55;
  word-break: break-word;
}

.meta-text,
.history-meta {
  margin: 8px 0 0;
}

.empty-state {
  min-height: 360px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.28);
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.history-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
}

.history-image-link {
  display: block;
  background: #efe7dd;
}

.history-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.history-body {
  padding: 12px;
}

.inline-link {
  text-decoration: none;
}

.inline-link:hover {
  color: var(--accent-strong);
}

.hidden {
  display: none !important;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: 100%;
  max-width: 460px;
}

.login-panel {
  padding: 28px;
}

@media (max-width: 960px) {
  .topbar,
  .layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar-panel {
    order: 2;
  }
}
