/* =====================================================
   BASE / RESET
   ===================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

:root {
  /* UI palette */
  --ui-bg: #FAF9F5;
  --ui-card: transparent;
  --ui-text: #111;
  --ui-muted: #666;
  --ui-border: #F4E7E0;
  --ui-block: #FAF9F5;


  /* Accent */
  --accent: #d97757;
  --accent-soft: #d9785748;

  /* Radii + spacing */
  --r-sm: 8px;
  --r-md: 12px;

  /* Focus ring */
  --focus: #d97757;
}

body {
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.4;
  background: var(--ui-bg);
  color: var(--ui-text);
}







/* =====================================================
   PAGE CONTAINER (THE ONLY WIDTH AUTHORITY)
   ===================================================== */

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px;
}






/* =====================================================
   GENERIC BLOCKS (VERTICAL FLOW ONLY)
   ===================================================== */

.block {
  width: 100%;
  margin-bottom: 18px;
  padding: 16px;
  border-radius: var(--r-md);
  border: 1px solid #f4e7e082;
  background: transparent;
}

.block.paper {
  border: none;
  padding: 0;
}







/* =====================================================
   CONTROLS
   ===================================================== */

.controls h1 {
  margin: 0 0 16px;
  font-size: 24px;
  font-weight: 600;
}

/* Layout rows */
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.label {
  font-weight: 500;
  color: var(--ui-text);
}

/* =====================================================
   Unified control base
   ===================================================== */

button,
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ui-text);

  background: rgba(0,0,0,0.025);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 10px;

  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    transform 60ms ease;
}

/* Contextual sizing — does NOT affect export detail fields */
.controls input[type="number"] {
  width: 72px;
}

.controls input[type="text"] {
  min-width: 160px;
}


/* =====================================================
   Buttons
   ===================================================== */

button {
  cursor: pointer;
}

button:hover {
  background: #eed5ca89;
  color: #D97757;
}

button:active {
  transform: translateY(1px);
}

/* Selected / active buttons */
button.is-active {
  background: #D97757;
  color: #ffffff;
}

/* =====================================================
   Inputs
   ===================================================== */

input[type="checkbox"] {
  transform: translateY(1px);
}

/* Focused (but not filled yet) */
input:focus-visible,
textarea:focus-visible {
  background: #fff;
  border-color: var(--ui-border);
  outline: none;
}

/* Filled-in inputs */
input:not(:placeholder-shown),
textarea:not(:placeholder-shown) {
  background: #fff;
  border: 1px solid var(--ui-border);
}

/* Inactive (disabled-by-logic, not by HTML) */
.is-inactive {
  background: rgba(0,0,0,0.015);
  color: #9a9a9a;
  border-color: transparent;
  pointer-events: none;
}









/* =====================================================
   TEXT INPUT
   ===================================================== */

.input textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  padding: 12px;
  font-size: 15px;
  border: 1px solid var(--ui-border);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--ui-text);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 1px solid var(--focus);
  outline-offset: 0px;
}






/* =====================================================
   PAPER PREVIEW (NO WIDTH LOGIC YET)
   ===================================================== */

.paper {
  border: 1px solid #ccc;
  padding: 16px;
}

.paper-inner {
  width: 100%;
  overflow: hidden;
  background: transparent;
  min-height: 120px;
}






/* =====================================================
   EXPORT
   ===================================================== */

.export {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}


.export span {
  font-weight: 500;
}

.export-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.export-details {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.export-details.hidden {
  display: none;
}

.export-details input {
  max-width: 320px;
}


.export-disclaimer {
  font-size: 12px;
  color: #666;
}






/* =====================================================
   PAPER GRID (STRUCTURAL ONLY)
   ===================================================== */

.paper-inner {
  display: flex;
  flex-direction: column;
}

.paper-row {
  display: grid;
  gap: 0;
  align-items: stretch;

  border-top: 1px solid #f4e7e0dd;
  border-bottom: none;
}



.paper-cell {
  border-right: 1px solid #f4e7e0dd;

  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;

  white-space: nowrap;
  overflow: hidden;

  /* ✅ responsive text sizing inside small squares */
  font-size: clamp(10px, 2.4vw, 14px);
  line-height: 1;
  padding: 1px;
}


.paper-row.gutter {
  display: block;
  position: relative;

  width: 100%;

  height: 12px;

  border-top: 1px solid #f4e7e0dd;
  border-left: 1px solid #f4e7e0dd;
  border-right: 1px solid #f4e7e0dd;
}

.gutter-counter {
  position: absolute;
  right: 6px;
  bottom: 1px;

  font-size: 7px;
  color: #d97857a2;
  user-select: none;
}

.paper-cell:first-child {
  border-left: 1px solid #f4e7e0dd;
}

.paper-cell.overflow {
  background-color: transparent;
  color: #d97757;
}

.paper-cell.punct-left {
  justify-content: flex-start;
  padding-left: 3px;
}


.paper-row:last-child {
  border-bottom: 1px solid #f4e7e0dd;
}






/* =====================================================
   STATS BLOCK
   ===================================================== */

   .stats {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--ui-border);
  background: rgba(255,255,255,0.6);
  color: var(--ui-text);
  font-size: 14px;
}

.stats .bad {
  font-weight: 700;
}
