:root {
  color-scheme: light;
  --paper: #2a1a10;
  --surface: #f4e7c8;
  --ink: #302014;
  --muted: #786148;
  --line: #c4a36c;
  --forest: #65402a;
  --forest-dark: #2b190f;
  --copper: #a84e22;
  --copper-pale: #f0dfbb;
  --amber: #d0a04c;
  --shadow: 0 12px 32px rgb(24 12 5 / 28%);
  font-family: "DM Sans", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: #f3e6cc;
  background-color: var(--paper);
  background-image: linear-gradient(rgb(25 14 8 / 18%), rgb(25 14 8 / 28%)), url("./assets/backgrounds/daily-calculator-background.jpeg");
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;
}

button, input { font: inherit; }
button, label { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; animation: arrive 420ms ease-out both; }

.topbar {
  height: 64px;
  padding: 0 clamp(18px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #f9f1df;
  background: rgb(39 22 13 / 94%);
  border-bottom: 3px solid #c48a3a;
}

.calculator-menu { position: relative; color: #f9f1df; }
.calculator-menu summary {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 1px solid #9a744d;
  border-radius: 4px;
  color: inherit;
  background: #24140c;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.calculator-menu summary::-webkit-details-marker { display: none; }
.menu-caret {
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 1.5px solid #e6d3b2;
  border-bottom: 1.5px solid #e6d3b2;
  transform: rotate(45deg);
  transition: transform 120ms ease;
}
.calculator-menu[open] .menu-caret { margin-top: 4px; transform: rotate(225deg); }
.calculator-menu-list {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 5;
  min-width: 205px;
  overflow: hidden;
  border: 1px solid #9a744d;
  border-radius: 4px;
  background: var(--forest-dark);
  box-shadow: 0 10px 24px rgb(13 8 4 / 40%);
}
.calculator-menu-list a, .calculator-menu-list button {
  width: 100%;
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 13px;
  border: 0;
  color: #f1e4cd;
  background: transparent;
  text-align: left;
  text-decoration: none;
  font: 500 12px/1.2 "DM Sans", sans-serif;
}
.calculator-menu-list a:hover, .calculator-menu-list a[aria-current="page"] { color: #fff7e2; background: #624128; }
.calculator-menu-list button:disabled { color: #b7a58b; opacity: 0.72; }
.topbar-right { display: flex; align-items: center; gap: 12px; color: #e4d3b7; font-size: 12px; }
.language-switch { display: flex; gap: 2px; padding: 2px; border: 1px solid #9a744d; border-radius: 4px; background: #24140c; }
.language-switch button {
  min-width: 29px;
  height: 24px;
  padding: 0 5px;
  border: 0;
  border-radius: 2px;
  color: #e4d3b7;
  background: transparent;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.language-switch button[aria-pressed="true"] { color: #2b190f; background: #e8d2a7; }
.language-switch button:focus-visible, .calculator-menu summary:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.main-content { position: relative; isolation: isolate; width: min(1800px, 100%); margin: 0 auto; padding: 30px clamp(18px, 3vw, 48px) 46px; }
.page-heading { display: flex; align-items: center; justify-content: center; margin-bottom: 22px; text-align: center; }
.page-heading > div { width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  color: #f7ebd2;
  font: 600 38px/1 "Barlow Condensed", sans-serif;
  letter-spacing: 0.1px;
  text-shadow: 0 2px 5px rgb(20 10 4 / 70%);
}
h2 { margin: 0; color: #f7ebd2; font: 600 25px/1 "Barlow Condensed", sans-serif; text-shadow: 0 2px 4px rgb(20 10 4 / 65%); }
h3 { margin: 0; font-size: 14px; font-weight: 700; }

.control-strip {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 30px;
  padding: 13px 20px;
  border: 1px solid #d0ad72;
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.days-control { display: flex; align-items: center; gap: 14px; }
.control-label, .metric-label { color: #766044; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.days-control input {
  width: 68px;
  height: 42px;
  padding: 0 8px;
  border: 1px solid #b99a66;
  border-radius: 4px;
  color: #3c2a18;
  background: #fbf2df;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}
.strip-divider { width: 1px; height: 40px; background: #c9b28a; }
.metric { min-width: 90px; display: grid; gap: 4px; }
.metric strong { color: #382519; font: 600 21px/1 "Barlow Condensed", sans-serif; }
.text-button { margin-left: auto; padding: 8px 0; border: 0; color: #65402a; background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.text-button:disabled { color: #9d8b70; cursor: default; }

.notice { min-height: 38px; margin: 14px 0 22px; padding: 10px 13px; border-left: 3px solid var(--amber); color: #49331f; background: #f8e9c9; font-size: 12px; line-height: 1.5; }
.notice strong { color: var(--ink); }
.notice-warning { border-left-color: var(--copper); background: var(--copper-pale); }

.workspace-grid { display: grid; grid-template-columns: minmax(620px, 1.55fr) minmax(430px, 0.95fr); align-items: start; gap: 28px; }
.professions-section, .materials-section { min-width: 0; }
.section-heading { min-height: 50px; display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.profession-list { display: grid; gap: 17px; }
.profession-band { min-width: 0; padding: 11px; border: 1px solid #b87639; border-top: 4px solid #a7190d; background: rgb(87 43 22 / 92%); box-shadow: 0 4px 12px rgb(30 15 7 / 28%); }
.band-heading { margin: -11px -11px 10px; padding: 4px 10px; color: #fff2d7; background: #77190e; text-align: center; font: 700 11px/1.2 "DM Sans", sans-serif; letter-spacing: 1px; }
.profession-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 7px; }
.profession-card { min-width: 0; padding: 6px; border: 1px solid #bd8747; background: #eddbb5; }
.profession-card-heading { min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 5px; padding-bottom: 6px; border-bottom: 1px solid #c8a66a; text-align: center; }
.profession-icon { width: 40px; height: 40px; flex: 0 0 40px; object-fit: contain; image-rendering: pixelated; }
.profession-card h4 { min-height: 23px; display: flex; align-items: center; justify-content: center; margin: 0; color: #352417; font-size: 10px; font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.level-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding-top: 6px; }
.level-toggle { position: relative; min-width: 0; height: 23px; display: grid; place-items: center; border: 1px solid #c5aa7a; border-radius: 2px; color: #51402d; background: #fff4d9; cursor: pointer; transition: color 120ms ease, background 120ms ease, border-color 120ms ease; }
.level-toggle:hover { border-color: #54663b; }
.level-toggle.is-active { border-color: #30543a; color: #fff5d9; background: #36583c; box-shadow: inset 0 0 0 1px #d0a04c; }
.level-toggle input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.level-toggle:focus-within { outline: 2px solid var(--amber); outline-offset: 2px; }
.level-toggle span { pointer-events: none; font-size: 10px; font-weight: 700; }
.empty-state { padding: 30px 16px; color: #755c3e; text-align: center; font-size: 13px; }
.compact-empty { border-bottom: 1px solid #c8a66a; }

.materials-section, .potion-list-section, .recipe-list-section { min-width: 0; }
.materials-section { padding: 0 0 4px; }
.potion-list-section { min-width: 0; }
.potion-table { min-width: 720px; }
.potion-table-wrap { max-height: 68vh; }
.potion-level { width: 68px; color: #65402a; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.potion-name { min-width: 230px; font-weight: 600; }
.potion-effect { min-width: 270px; color: #745e43; }
.potion-quantity-column { width: 106px; padding: 0 11px; text-align: right; }
.potion-quantity-input { width: 82px; height: 29px; padding: 0 8px; border: 1px solid #bea06d; border-radius: 3px; color: #392719; background: #fff5dc; text-align: right; font-size: 12px; font-weight: 700; }
.potion-quantity-input:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }
.materials-heading { margin-bottom: 14px; }
.export-button { min-height: 34px; padding: 0 12px; border-color: #9b744a; color: #51331e; background: #eddbb5; font-size: 11px; }
.export-button:not(:disabled):hover { color: #fff4dd; background: #65402a; }
.export-button:disabled { color: #968064; cursor: default; }
.search-control { height: 39px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid #c5a771; border-radius: 4px; background: var(--surface); }
.search-symbol { color: #65402a; font-size: 22px; line-height: 1; transform: rotate(-20deg); }
.search-control input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.table-wrap { width: 100%; max-height: 62vh; min-height: 180px; overflow: auto; margin-top: 10px; border-top: 2px solid #684126; border-bottom: 1px solid #c5a771; background: var(--surface); }
table { width: 100%; min-width: 510px; border-collapse: collapse; color: var(--ink); background: var(--surface); text-align: left; }
thead { position: sticky; top: 0; z-index: 1; background: #e7d2a8; }
th { height: 35px; padding: 0; color: #58432b; font-size: 10px; font-weight: 700; letter-spacing: 0.8px; }
.sort-button { width: 100%; height: 35px; display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 0 11px; border: 0; color: inherit; background: transparent; text-align: left; font-size: inherit; font-weight: inherit; letter-spacing: inherit; cursor: pointer; }
.sort-button:hover { color: #321d0f; background: #dbc28e; }
.sort-button:focus-visible { outline: 2px solid var(--amber); outline-offset: -3px; }
.sort-indicator { color: #9a481e; font-size: 12px; }
.quantity-column { width: 106px; text-align: right; font-variant-numeric: tabular-nums; }
.quantity-column .sort-button { justify-content: flex-end; }
td { height: 35px; padding: 0 11px; border-top: 1px solid #dfd0ae; font-size: 12px; }
tbody tr:hover { background: #f8edda; }
td.quantity-column { color: #49311d; font-weight: 700; }
.profession-column { width: 126px; }
.source-badge { min-height: 21px; display: inline-flex; align-items: center; padding: 0 7px; border-radius: 3px; font-size: 10px; font-weight: 700; white-space: nowrap; }
.source-gathered { color: #35523a; background: #dce3c1; }
.source-buyable { color: #7d3d1e; background: #f1d7a9; }
.source-dropped { color: #485762; background: #dce1dc; }
.source-unknown { color: #61513d; background: #e1d6c1; }
.empty-table { height: 100px; color: #755c3e; text-align: center; }
.materials-foot { display: flex; justify-content: space-between; gap: 14px; padding: 12px 1px; color: #f0dfc1; font-size: 11px; text-shadow: 0 1px 3px #1b1008; }
.materials-foot strong { color: #fff0ce; font-size: 12px; }
.app-footer { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(18px, 4vw, 64px); border-top: 1px solid rgb(225 188 124 / 45%); color: #e0caa4; font-size: 10px; letter-spacing: 0.5px; text-shadow: 0 1px 3px #1b1008; }

@keyframes arrive { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1120px) {
  .workspace-grid { grid-template-columns: 1fr; gap: 34px; }
  .materials-section { grid-row: 1; }
  .table-wrap { max-height: 42vh; }
  .potion-materials-section { grid-row: 2; }
  .recipe-materials-section { grid-row: 2; }
  .potion-table-wrap { max-height: 58vh; }
}
@media (max-width: 900px) {
  .profession-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  .topbar { height: 58px; padding-inline: 16px; }
  .topbar-right { gap: 8px; }
  .main-content { padding: 26px 16px 38px; }
  .page-heading { align-items: center; flex-direction: column; gap: 15px; }
  h1 { font-size: 34px; }
  .control-strip { min-width: 0; min-height: auto; flex-wrap: wrap; gap: 15px 20px; padding: 13px; }
  .strip-divider { height: 34px; }
  .metric { min-width: 72px; }
  .text-button { flex: 1 0 100%; width: 100%; margin: 0; text-align: left; }
  .workspace-grid { min-width: 0; }
  .materials-section { min-width: 0; }
  .table-wrap { width: 100%; max-height: 42vh; overflow-x: auto; overscroll-behavior-inline: contain; }
  .profession-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .profession-band { padding: 8px; }
  .band-heading { margin: -8px -8px 8px; }
  .profession-card { padding: 5px; }
  .profession-card-heading { min-height: 74px; }
  .level-grid { gap: 4px; }
  .level-toggle { height: 26px; }
  .materials-heading { align-items: end; }
  .app-footer { align-items: start; flex-direction: column; justify-content: center; padding-block: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
