:root {
  color-scheme: light;
  font-family: Inter, "Noto Sans JP", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f3ef;
  color: #20231f;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4f3ef; }
button, input, select, textarea { font: inherit; }
button, a { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px; display: flex; flex-direction: column; gap: 8px;
  background: #20231f; color: #fff;
}
.sidebar strong { margin: 0 8px 18px; font-size: 1.2rem; }
.sidebar button, .ghost-link, .secondary, .primary {
  min-height: 40px; border: 0; border-radius: 8px; padding: 10px 14px; text-decoration: none; font-weight: 700;
}
.sidebar button { text-align: left; color: #fff; background: transparent; }
.sidebar button:hover { background: #343b33; }
.workspace { padding: 28px; max-width: 1280px; width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.topbar h1, .login-panel h1, .public-header h1 { margin: 4px 0 0; line-height: 1.05; letter-spacing: 0; }
.eyebrow { color: #68735d; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
.ghost-link, .secondary { background: #e6e2d8; color: #20231f; }
.primary { background: #486245; color: #fff; }
.panel, .metric-grid article {
  background: #fffdfa; border: 1px solid #ddd8ca; border-radius: 8px; padding: 20px;
}
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric-grid span { color: #68735d; }
.metric-grid strong { display: block; font-size: 2.3rem; margin-top: 8px; }
.split, .print-layout, .edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .8fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.button-row, .filters, .toggle-row, .tag-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.qr-panel img { width: 180px; background: #fff; border: 1px solid #ddd8ca; }
code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; color: #486245; }

.sake-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.sake-card, .public-card {
  border: 1px solid #ddd8ca; border-radius: 8px; background: #fff; padding: 14px; text-align: left;
}
.sake-card { display: grid; grid-template-columns: 92px 1fr; gap: 14px; }
.sake-card img, .row img, .public-card img, .label-stack img, .modal img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; border: 1px solid #ddd8ca; }
.sake-card h3, .public-card h2 { margin: 8px 0 6px; }
.sake-card p, .public-card p { margin: 0 0 10px; color: #4d554c; line-height: 1.55; }
.badge { display: inline-block; border-radius: 999px; padding: 4px 9px; background: #e8efe4; color: #2f5936; font-size: .82rem; font-weight: 800; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; color: #384036; }
input, select, textarea {
  width: 100%; border: 1px solid #cfc8b9; border-radius: 7px; background: #fff; padding: 10px 11px; color: #20231f;
}
textarea { min-height: 108px; resize: vertical; }
.wide, .note, .error { grid-column: 1 / -1; }
.note { color: #68735d; line-height: 1.5; }
.error { color: #9b2f2f; }
.upload-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.upload {
  min-height: 220px; place-items: center; border: 2px dashed #bdb5a5; border-radius: 8px; background: #faf7ee; text-align: center;
}
.upload input { max-width: 220px; }
.label-stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.table { display: grid; gap: 8px; margin-top: 14px; }
.row {
  display: grid; grid-template-columns: 58px 1.4fr .8fr .7fr .7fr 1.1fr .8fr .7fr; gap: 10px; align-items: center;
  width: 100%; border: 1px solid #e2ddcf; border-radius: 8px; background: #fff; padding: 10px; text-align: left;
}
.row small { display: block; color: #68735d; margin-top: 4px; }
.mini-button { border-radius: 7px; padding: 7px 8px; background: #e6e2d8; text-align: center; font-weight: 700; }
.empty { padding: 24px; color: #68735d; }

.a4 {
  width: min(100%, 520px); min-height: 735px; padding: 34px; background: #fffdfa; border: 1px solid #cfc8b9; box-shadow: 0 12px 40px #0001;
}
.a4 h2 { text-align: center; margin-top: 0; font-size: 2rem; }
.a4 section { border-top: 1px solid #ded8ca; padding: 14px 0; }
.qr-small { width: 92px; display: block; margin: 22px auto 0; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #f4f3ef, #e8efe4); }
.login-panel { width: min(460px, 100%); padding: 32px; border-radius: 8px; background: #fffdfa; border: 1px solid #ddd8ca; }
.public-shell { max-width: 720px; margin: 0 auto; padding: 22px 16px 48px; }
.public-header { padding: 26px 0 18px; }
.public-header p { line-height: 1.65; color: #4d554c; }
.tag-row { position: sticky; top: 0; background: #f4f3ef; padding: 10px 0; z-index: 2; }
.tag-row a { border-radius: 999px; padding: 8px 12px; background: #e6e2d8; color: #20231f; text-decoration: none; font-weight: 700; }
.public-list { display: grid; gap: 14px; }
.public-card { display: grid; grid-template-columns: 120px 1fr; gap: 12px; }
.public-card img { grid-row: span 4; }
.modal-backdrop { position: fixed; inset: 0; display: grid; place-items: center; padding: 18px; background: #0008; z-index: 5; }
.modal { max-width: 520px; max-height: 92vh; overflow: auto; border-radius: 8px; background: #fffdfa; padding: 20px; position: relative; }
.modal img { max-width: 180px; display: block; margin: 0 auto 12px; }
.close { position: absolute; top: 10px; right: 10px; border: 0; border-radius: 50%; width: 36px; height: 36px; background: #e6e2d8; font-size: 1.4rem; }
dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px; }
dt { font-weight: 800; color: #68735d; }
dd { margin: 0; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px; }
  .workspace { padding: 18px 14px; }
  .topbar, .split, .print-layout, .edit-layout, .metric-grid, .sake-cards, .upload-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar { display: grid; }
  .row { grid-template-columns: 52px 1fr; }
  .row span:nth-child(n+3) { display: none; }
  .public-card { grid-template-columns: 96px 1fr; }
}

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .panel, .button-row { display: none !important; }
  .app-shell, .workspace, .print-layout { display: block; padding: 0; }
  .a4 { width: 210mm; min-height: 297mm; border: 0; box-shadow: none; }
}
