:root{
    --bg: #1b120c;
    --bg-panel: #241a12;
    --bg-panel-raised: #2c2015;
    --line: #3d2e1f;
    --cream: #f1e6d3;
    --cream-dim: #c9baa4;
    --amber: #cf8a3c;
    --amber-bright: #e8a751;
    --sour: #8ba362;
    --sour-dim: #5b6a44;
    --bitter: #a1493f;
    --bitter-dim: #6b3630;
    --sweet: #e0b24a;
    --body-color: #b98550;
    --clarity-color: #7fa7a1;
    --radius: 14px;
  }

  * { box-sizing: border-box; }

  body{
    margin:0;
    background:
      radial-gradient(ellipse 900px 500px at 15% -10%, #2a1c11 0%, transparent 60%),
      radial-gradient(ellipse 700px 500px at 100% 10%, #23180f 0%, transparent 55%),
      var(--bg);
    color: var(--cream);
    font-family: 'Inter', sans-serif;
    padding: 28px 20px 60px;
    -webkit-font-smoothing: antialiased;
  }

  .wrap{ max-width: 1180px; margin: 0 auto; }

  header{ margin-bottom: 28px; }
  .eyebrow{
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--amber-bright);
    display:flex; align-items:center; gap:10px;
    margin-bottom: 10px;
  }
  .eyebrow::before{
    content:"";
    width: 20px; height:1px;
    background: var(--amber-bright);
  }
  h1{
    font-family:'Fraunces', serif;
    font-weight: 600;
    font-size: clamp(28px, 4vw, 42px);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
  }
  header p{
    color: var(--cream-dim);
    max-width: 640px;
    line-height: 1.55;
    margin: 0;
    font-size: 15px;
  }

  .grid{
    display:grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items:start;
  }
  @media (max-width: 860px){
    .grid{ grid-template-columns: 1fr; }
  }

  .card{
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px;
  }

  .card h2{
    font-family:'Fraunces', serif;
    font-weight:600;
    font-size: 18px;
    margin: 0 0 4px;
  }
  .card .sub{
    font-size: 12.5px;
    color: var(--cream-dim);
    margin: 0 0 20px;
  }

  /* Presets */
  .presets{ display:flex; flex-wrap:wrap; gap:8px; margin-bottom: 22px; }
  .preset-btn{
    font-family:'Inter'; font-size: 12.5px; font-weight:600;
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    color: var(--cream-dim);
    padding: 7px 12px 7px 10px;
    border-radius: 100px;
    cursor:pointer;
    display:flex; align-items:center; gap:6px;
    transition: border-color .15s, color .15s, background .15s;
  }
  .preset-btn .btn-icon{ display:flex; color: var(--amber-bright); }
  .preset-btn .btn-icon svg{ width:14px; height:14px; display:block; }
  .preset-btn.active .btn-icon{ color: #241708; }
  .preset-btn:hover{ border-color: var(--amber); color: var(--cream); }
  .preset-btn.active{
    background: var(--amber);
    border-color: var(--amber);
    color: #241708;
  }
  .preset-btn:focus-visible, input:focus-visible, button:focus-visible{
    outline: 2px solid var(--amber-bright);
    outline-offset: 2px;
  }

  .brewer-badge{
    display:flex; align-items:center; gap:8px;
    font-family:'JetBrains Mono', monospace;
    font-size: 11.5px;
    color: var(--cream-dim);
    background: var(--bg-panel-raised);
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 22px;
  }
  .brewer-badge .badge-shape{ color: var(--cream); font-weight:700; }
  .brewer-badge .badge-sep{ color: #5a4a38; }
  .brewer-badge .badge-bypass{ color: var(--amber-bright); font-weight:700; }
  .brewer-badge .badge-icon{ display:flex; color: var(--amber-bright); }
  .brewer-badge .badge-icon svg{ width:16px; height:16px; display:block; }

  /* Sliders */
  .control{ margin-bottom: 20px; }
  .control:last-child{ margin-bottom: 0; }
  .control-label{
    display:flex; justify-content:space-between; align-items:baseline;
    margin-bottom: 8px;
  }
  .control-label .name{ font-size: 13.5px; font-weight:600; color: var(--cream); }
  .control-label .val{
    font-family:'JetBrains Mono', monospace;
    font-size: 13px;
    color: var(--amber-bright);
    font-weight: 700;
  }
  .control .range-labels{
    display:flex; justify-content:space-between;
    font-size: 10.5px; color: #8a7a63;
    margin-top: 6px;
    font-family:'JetBrains Mono', monospace;
  }

  input[type="range"]{
    -webkit-appearance:none; appearance:none;
    width:100%; height: 6px;
    background: var(--line);
    border-radius: 4px;
    outline-offset: 4px;
  }
  input[type="range"]::-webkit-slider-thumb{
    -webkit-appearance:none;
    width:18px; height:18px; border-radius:50%;
    background: var(--amber-bright);
    border: 3px solid #241708;
    cursor:pointer;
    margin-top: -6px;
    box-shadow: 0 0 0 1px var(--amber-bright);
  }
  input[type="range"]::-moz-range-thumb{
    width:18px; height:18px; border-radius:50%;
    background: var(--amber-bright);
    border: 3px solid #241708;
    cursor:pointer;
    box-shadow: 0 0 0 1px var(--amber-bright);
  }
  input[type="range"]::-webkit-slider-runnable-track{ height:6px; border-radius:4px; }
  input[type="range"]::-moz-range-track{ height:6px; border-radius:4px; background: var(--line); }

  input[type="range"].roast-slider{
    background: linear-gradient(90deg, #d9b98c 0%, #a97c50 35%, #6b4530 65%, #33211a 100%);
  }
  input[type="range"].roast-slider::-webkit-slider-runnable-track{ background: transparent; }
  input[type="range"].roast-slider::-moz-range-track{ background: transparent; }

  .roast-hint{
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--cream-dim);
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    line-height: 1.45;
  }
  .roast-hint b, .water-hint b{ color: var(--amber-bright); font-weight:700; }
  .water-hint{
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--cream-dim);
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    line-height: 1.45;
  }
  .water-hint.warn b{ color: var(--bitter); }
  input[type="range"]:disabled{ opacity:0.35; cursor:not-allowed; }
  input[type="range"]:disabled::-webkit-slider-thumb{ cursor:not-allowed; }

  .bypass-note{
    margin-top: 8px;
    font-size: 11.5px;
    color: var(--amber-bright);
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 10px;
    line-height: 1.45;
    display:none;
  }
  .bypass-note.show{ display:block; }

  /* Right column stacking */
  .right-col{ display:flex; flex-direction:column; gap:20px; }

  /* Chart */
  .chart-card .chart-wrap{ position:relative; width:100%; }
  svg{ width:100%; height:auto; display:block; overflow:visible; }
  .axis-label{
    font-family:'JetBrains Mono', monospace;
    font-size: 10.5px;
    fill: #8a7a63;
  }
  .zone-label{
    font-family:'Inter'; font-size: 10.5px; font-weight:600;
    fill: #6c5c48;
    letter-spacing: 0.02em;
  }
  .ideal-label{
    font-family:'JetBrains Mono', monospace;
    font-size: 10px; font-weight:700;
    fill: var(--amber-bright);
    letter-spacing: 0.08em;
  }
  .dot-outer, .dot-bed{ transition: cx .35s cubic-bezier(.2,.8,.2,1), cy .35s cubic-bezier(.2,.8,.2,1); }
  .dot-core{ transition: cx .35s cubic-bezier(.2,.8,.2,1), cy .35s cubic-bezier(.2,.8,.2,1); }
  .dilution-line{ transition: x1 .35s cubic-bezier(.2,.8,.2,1), y1 .35s cubic-bezier(.2,.8,.2,1), x2 .35s cubic-bezier(.2,.8,.2,1), y2 .35s cubic-bezier(.2,.8,.2,1); }
  @media (prefers-reduced-motion: reduce){
    .dot-outer, .dot-core, .dot-bed, .dilution-line{ transition: none; }
  }

  .verdict{
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    font-size: 14px;
    line-height: 1.5;
    display:flex; gap:12px; align-items:flex-start;
  }
  .verdict .tag{
    font-family:'JetBrains Mono', monospace;
    font-size: 11px; font-weight:700;
    letter-spacing:0.06em;
    padding: 3px 9px;
    border-radius: 100px;
    white-space:nowrap;
    margin-top: 1px;
  }

  /* Flavor bars */
  .bars{ display:flex; flex-direction:column; gap:16px; }
  .bar-row .bar-top{
    display:flex; justify-content:space-between; margin-bottom:6px;
  }
  .bar-row .bar-name{ font-size: 13px; font-weight:600; }
  .bar-row .bar-val{
    font-family:'JetBrains Mono', monospace; font-size:12.5px; font-weight:700;
  }
  .bar-track{
    width:100%; height:10px; border-radius:6px;
    background: var(--line);
    overflow:hidden;
  }
  .bar-fill{
    height:100%; border-radius:6px;
    transition: width .35s cubic-bezier(.2,.8,.2,1);
  }
  @media (prefers-reduced-motion: reduce){ .bar-fill{ transition:none; } }

  .stats-row{
    display:flex; gap: 14px; margin-top: 18px; flex-wrap:wrap;
  }
  .stat{
    flex:1; min-width: 120px;
    background: var(--bg-panel-raised);
    border:1px solid var(--line);
    border-radius: 10px;
    padding: 10px 14px;
  }
  .stat .label{ font-size:10.5px; color:var(--cream-dim); text-transform:uppercase; letter-spacing:.06em; }
  .stat .value{ font-family:'JetBrains Mono', monospace; font-size:18px; font-weight:700; color: var(--amber-bright); margin-top:2px; }
  .stat .range{ font-size: 10px; color:#8a7a63; margin-top:2px; }

  .chart-legend{
    display:flex; gap:18px; flex-wrap:wrap;
    margin-top: 12px;
    font-size: 11.5px; color: var(--cream-dim);
  }
  .chart-legend span{ display:flex; align-items:center; gap:6px; }
  .dot-swatch{
    width:9px; height:9px; border-radius:50%; display:inline-block;
  }
  .dot-swatch-cup{ background: var(--amber-bright); }
  .dot-swatch-bed{ background: transparent; border: 1.5px dashed var(--amber-bright); }

  footer{
    margin-top: 24px;
    font-size: 11.5px;
    color: #6c5c48;
    line-height:1.6;
  }

  /* Identity bar */
  .identity-bar{
    margin-bottom: 14px;
    font-family:'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--cream-dim);
    text-align: right;
  }
  .id-row{ display:flex; align-items:center; justify-content:flex-end; gap:10px; }
  .identity-bar .id-name{ color: var(--amber-bright); font-weight:700; }
  .identity-bar button{
    font-family:'Inter'; font-size: 12px; font-weight:600;
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    color: var(--cream-dim);
    padding: 5px 12px;
    border-radius: 100px;
    cursor:pointer;
  }
  .identity-bar button:hover{ border-color: var(--amber); color: var(--cream); }
  .identity-form{ display:flex; gap:8px; align-items:center; }
  .identity-form input[type="text"]{
    font-family:'Inter'; font-size: 13px;
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    color: var(--cream);
    padding: 6px 10px;
    border-radius: 8px;
    width: 160px;
  }

  /* Tabs */
  .tabs{
    display:flex; gap:6px; margin-bottom: 22px;
    border-bottom: 1px solid var(--line);
  }
  .tab-btn{
    font-family:'Inter'; font-size: 13.5px; font-weight:600;
    background: transparent;
    border: none;
    color: var(--cream-dim);
    padding: 10px 6px;
    margin-right: 18px;
    cursor:pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
  }
  .tab-btn:hover{ color: var(--cream); }
  .tab-btn.active{ color: var(--amber-bright); border-bottom-color: var(--amber-bright); }
  .tab-panel{ display:none; }
  .tab-panel.active{ display:block; }

  /* Text / select inputs for the log form */
  .text-input, select.text-input{
    width:100%;
    font-family:'Inter'; font-size: 13.5px;
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    color: var(--cream);
    padding: 9px 11px;
    border-radius: 8px;
  }
  .text-input:focus-visible, select.text-input:focus-visible{
    outline: 2px solid var(--amber-bright); outline-offset:1px;
  }
  textarea.text-input{ resize: vertical; min-height: 64px; font-family:'Inter'; }
  .field-row{ display:grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  @media (max-width: 640px){ .field-row{ grid-template-columns: 1fr; } }

  .section-divider{
    margin: 22px 0 16px;
    padding-top: 18px;
    border-top: 1px dashed var(--line);
  }
  .section-divider h3{
    font-family:'Fraunces', serif; font-weight:600; font-size:15px; margin:0 0 4px;
  }
  .section-divider p{ font-size:12px; color:var(--cream-dim); margin:0; }

  /* Star rating */
  .star-rating{ display:flex; gap:4px; }
  .star-btn{
    background:none; border:none; cursor:pointer;
    font-size: 26px; line-height:1; padding:2px;
    color: var(--line);
    transition: color .12s;
  }
  .star-btn.filled{ color: var(--amber-bright); }
  .star-btn:hover{ color: var(--amber); }

  .save-btn{
    font-family:'Inter'; font-size: 14px; font-weight:700;
    background: var(--amber-bright);
    color: #241708;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor:pointer;
    margin-top: 18px;
  }
  .save-btn:hover{ background: var(--amber); }
  .save-btn:disabled{ opacity:0.4; cursor:not-allowed; }

  .save-toast{
    margin-top: 12px;
    font-size: 13px;
    color: var(--sweet);
    display:none;
  }
  .save-toast.show{ display:block; }

  /* Predicted mini profile */
  .predicted-box{
    background: var(--bg-panel-raised);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 16px;
    margin-top: 4px;
  }
  .predicted-stats{ display:flex; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
  .predicted-stats .pstat{ font-family:'JetBrains Mono', monospace; font-size:12.5px; color:var(--cream-dim); }
  .predicted-stats .pstat b{ color: var(--amber-bright); }

  /* History */
  .history-controls{ display:flex; gap:8px; margin-bottom:18px; }
  .filter-btn{
    font-family:'Inter'; font-size:12.5px; font-weight:600;
    background: var(--bg-panel-raised);
    border:1px solid var(--line);
    color: var(--cream-dim);
    padding: 7px 14px;
    border-radius: 100px;
    cursor:pointer;
  }
  .filter-btn.active{ background: var(--amber); border-color: var(--amber); color:#241708; }

  .log-card{
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
  }
  .log-card-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:10px; margin-bottom:8px; }
  .log-card-title{ font-family:'Fraunces', serif; font-weight:600; font-size:16px; }
  .log-card-meta{ font-size:11.5px; color:var(--cream-dim); margin-top:2px; }
  .log-card-stars{ font-size:15px; color: var(--amber-bright); white-space:nowrap; }
  .log-chips{ display:flex; flex-wrap:wrap; gap:6px; margin: 8px 0; }
  .log-chip{
    font-family:'JetBrains Mono', monospace; font-size:11px;
    background: var(--bg-panel-raised);
    border:1px solid var(--line);
    border-radius: 100px;
    padding: 3px 10px;
    color: var(--cream-dim);
  }
  .log-card-notes{ font-size:13px; color:var(--cream-dim); line-height:1.5; margin-top:8px; font-style:italic; }
  .log-card-delete{
    font-family:'Inter'; font-size:11.5px; font-weight:600;
    background:none; border:1px solid var(--bitter-dim); color: var(--bitter);
    padding:4px 10px; border-radius:100px; cursor:pointer; margin-top:10px;
  }
  .log-card-delete:hover{ background: var(--bitter-dim); color: var(--cream); }
  .log-card-try{
    font-family:'Inter'; font-size:11.5px; font-weight:600;
    background:none; border:1px solid var(--amber); color: var(--amber-bright);
    padding:4px 10px; border-radius:100px; cursor:pointer; margin-top:10px;
  }
  .log-card-try:hover{ background: var(--amber-bright); color:#241708; }
  .empty-state{ color: var(--cream-dim); font-size:13.5px; padding: 20px 0; text-align:center; }

  .admin-only{ display:none; }

  .disclaimer{
    font-size: 11.5px;
    color: var(--cream-dim);
    background: var(--bg-panel-raised);
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    line-height: 1.5;
    margin-top: 10px;
    text-align: left;
  }
  .disclaimer b{ color: var(--amber-bright); }

  .id-forms{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end; }
  .id-forms button.secondary{ background:transparent; }
  .id-msg{ font-size:11.5px; margin-top:6px; text-align:right; }

  .user-row{
    display:flex; align-items:center; justify-content:space-between; gap:10px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 10px;
  }
  .user-row .u-name{ font-weight:700; font-size:14px; }
  .user-row .u-meta{ font-size:11.5px; color:var(--cream-dim); margin-top:2px; }
  .admin-badge{
    font-family:'JetBrains Mono', monospace; font-size:10px; font-weight:700;
    background: var(--amber-bright); color:#241708;
    padding: 2px 8px; border-radius:100px; margin-left:8px;
  }
  .user-row-actions{ display:flex; gap:6px; }
  .user-row-actions button{
    font-family:'Inter'; font-size:11.5px; font-weight:600;
    background: var(--bg-panel-raised);
    border:1px solid var(--line);
    color: var(--cream-dim);
    padding: 5px 11px;
    border-radius: 100px;
    cursor:pointer;
  }
  .user-row-actions button:hover{ border-color: var(--amber); color: var(--cream); }
  .user-row-actions button.danger:hover{ border-color: var(--bitter); color: var(--bitter); }
