/* Windows 3.11–inspired: typography-first, flat chrome, no radius */

:root {
  --desktop: #c0c0c0;
  --surface: #c0c0c0;
  --window: #ffffff;
  --text: #000000;
  --muted: #404040;
  --title: #000080;
  --title-text: #ffffff;
  --face: #c0c0c0;
  --light: #ffffff;
  --shadow: #808080;
  --dark: #000000;
  --select-bg: #000080;
  --select-fg: #ffffff;
  --error: #800000;
  --ok: #008000;

  --font-ui: "Tahoma", "MS Sans Serif", "Segoe UI", Geneva, sans-serif;
  --font-display: "Times New Roman", Times, "Liberation Serif", serif;
  --size: 13px;
  --size-sm: 11px;
  --size-lg: 15px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: var(--size);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.35;
  color: var(--text);
  background-color: var(--desktop);
  /* subtle 3.11 desktop dither */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2'%3E%3Crect width='1' height='1' fill='%23b8b8b8'/%3E%3C/svg%3E");
}

a {
  color: var(--title);
  text-decoration: underline;
}

a:hover {
  color: #0000cc;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 1px dotted var(--dark);
  outline-offset: 1px;
}

/* —— Layout —— */

.wrap {
  max-width: 28rem;
  margin: 0 auto;
  padding: 1rem 0.75rem 2.5rem;
  position: relative;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.connection-status {
  margin-left: auto;
  font-size: var(--size-sm);
  color: var(--muted);
}

.connection-status.is-offline {
  color: var(--error);
  font-weight: 700;
}

.home-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.45rem;
  padding: 0;
  margin: 0;
  min-height: 0;
  text-decoration: none;
  color: var(--text);
}

.home-icon {
  display: block;
  shape-rendering: crispEdges;
}

.page-header {
  margin-bottom: 1rem;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.35rem;
  line-height: 1.1;
}

.lede {
  margin: 0 0 0.75rem;
  max-width: 26em;
}

.flow-steps {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  font-size: var(--size-sm);
  color: var(--muted);
  max-width: 26em;
}

.flow-steps li {
  margin-bottom: 0.2rem;
}

.flow-steps li:last-child {
  margin-bottom: 0;
}

.nav-link {
  font-size: var(--size-sm);
  margin-bottom: 0.5rem;
}

/* —— Window chrome —— */

.win {
  margin-bottom: 0.65rem;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--surface);
}

.win.admin-view .title-bar {
  background: #800000;
}

.title-bar {
  display: flex;
  align-items: center;
  min-height: 1.35rem;
  padding: 0.1rem 0.35rem;
  background: var(--title);
  color: var(--title-text);
  font-weight: 700;
  font-size: var(--size-sm);
  letter-spacing: 0.02em;
}

.title-bar-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-body {
  padding: 0.5rem;
  background: var(--surface);
}

.win-body > *:last-child {
  margin-bottom: 0;
}

/* —— Typography in windows —— */

.win-body h2,
.field-label {
  font-size: var(--size-sm);
  font-weight: 700;
  margin: 0 0 0.35rem;
  text-transform: none;
}

.hint,
.muted {
  font-size: var(--size-sm);
  color: var(--muted);
  margin: 0 0 0.5rem;
}

.kolli,
.status-line {
  font-weight: 700;
  margin: 0 0 0.35rem;
}

.kolli-secondary {
  font-weight: 400;
  font-size: var(--size-sm);
  color: var(--muted);
}

/* —— Form controls —— */

.options-fieldset {
  margin: 0.75rem 0;
  padding: 0.35rem 0.5rem 0.5rem;
  border: 1px solid var(--shadow);
  background: var(--window);
}

.options-fieldset .field-label {
  padding: 0 0.15rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0;
  font-size: var(--size-sm);
  cursor: default;
}

.checkbox-caption {
  cursor: default;
  user-select: none;
}

.win-checkbox,
.win-radio {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  margin: 0;
  background: var(--window);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  cursor: default;
}

.win-checkbox:checked,
.win-radio:checked {
  background-color: var(--window);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 11'%3E%3Cpath fill='%23000' d='M1 5.5 4 8.5 10 2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 9px 9px;
}

.win-radio {
  border-radius: 0;
}

.options-hint {
  margin: 0.15rem 0 0.5rem 1.35rem;
}

.beer-pick-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  cursor: default;
}

.beer-confirm-list .product-item.selected {
  background: var(--face);
}

.confirm-beer-row {
  margin-top: 0.5rem;
}

.field {
  margin-bottom: 0.5rem;
}

.field-label {
  display: block;
}

input[type="text"],
input[type="url"],
input[type="number"],
textarea {
  width: 100%;
  margin: 0 0 0.5rem;
  padding: 0.2rem 0.25rem;
  font: inherit;
  font-size: var(--size);
  color: var(--text);
  background: var(--window);
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
}

input.is-invalid,
textarea.is-invalid,
input:user-invalid,
textarea:user-invalid {
  border-color: var(--error) var(--light) var(--light) var(--error);
  background: #fff8f8;
}

input.is-invalid:focus-visible,
textarea.is-invalid:focus-visible,
input:focus:user-invalid,
textarea:focus:user-invalid {
  outline: 1px dotted var(--error);
  outline-offset: 1px;
}

.field-error {
  color: var(--error);
  font-size: var(--size-sm);
  font-weight: 700;
  margin: 0.2rem 0 0;
}

textarea {
  resize: vertical;
  min-height: 2.5rem;
}

input[readonly] {
  background: var(--window);
  color: var(--muted);
}

/* —— Buttons —— */

button,
.button {
  display: inline-block;
  margin: 0 0 0.35rem;
  padding: 0.2rem 0.65rem;
  font: inherit;
  font-size: var(--size);
  color: var(--text);
  background: var(--face);
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  cursor: default;
  text-decoration: none;
  text-align: center;
  min-height: 1.6rem;
}

button:active:not(:disabled),
.button:active {
  border-color: var(--dark) var(--light) var(--light) var(--dark);
  padding: 0.25rem 0.6rem 0.15rem 0.7rem;
}

button:disabled {
  color: var(--shadow);
  text-shadow: 1px 1px 0 var(--light);
}

button.primary,
.button.primary {
  font-weight: 700;
}

button.primary:not(:disabled) {
  outline: 1px dotted var(--dark);
  outline-offset: -4px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.btn-row button {
  margin-bottom: 0;
}

.link-row {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.link-row input {
  flex: 1;
  margin-bottom: 0;
}

.link-row button {
  flex-shrink: 0;
  margin-bottom: 0;
}

/* —— Inset fields (read-only / listbox) —— */

.inset-panel {
  padding: 0.3rem 0.4rem;
  margin-bottom: 0.35rem;
  border: 2px solid;
  border-color: var(--shadow) var(--light) var(--light) var(--shadow);
  background: var(--window);
}

.readonly-field {
  font-weight: 700;
  font-size: var(--size);
  line-height: 1.35;
}

.phase-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--shadow);
  background: var(--window);
}

.phase-step {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.25rem 0.4rem;
  font-size: var(--size-sm);
  border-bottom: 1px solid var(--face);
}

.phase-step-label {
  flex: 1;
  min-width: 6rem;
}

.phase-step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.phase-step-actions button {
  margin: 0;
  padding: 0.1rem 0.4rem;
  min-height: 1.4rem;
  font-size: var(--size-sm);
}

.phase-admin-block {
  margin-top: 0.5rem;
}

.phase-admin-hint {
  margin: 0 0 0.35rem;
}

.phase-step:last-child {
  border-bottom: none;
}

.phase-step-done {
  color: var(--muted);
}

.phase-step-done::before {
  content: "✓ ";
  font-weight: 700;
}

.phase-step-current {
  background: var(--select-bg);
  color: var(--select-fg);
  font-weight: 700;
}

.phase-step-current .hint {
  color: #c0c0c0;
}

.phase-hint {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.group-meta {
  margin: 0.35rem 0 0.5rem;
  font-size: var(--size-sm);
}

.group-swish {
  margin-bottom: 0;
}

.group-swish-line {
  margin: 0 0 0.15rem;
  font-size: var(--size-sm);
}

.group-swish-line .field-label {
  display: inline;
  margin-right: 0.35rem;
}

.group-swish-line a {
  font-weight: 700;
}

/* —— Lists & products —— */

.product-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--shadow);
  background: var(--window);
}

.product-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--face);
}

.product-item:last-child {
  border-bottom: none;
}

.product-item.selected {
  background: var(--select-bg);
  color: var(--select-fg);
}

.product-item.selected .product-info span,
.product-item.selected .link-out {
  color: var(--select-fg);
}

.product-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  border: 1px solid var(--shadow);
  background: var(--window);
}

.product-img.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--size-sm);
  font-weight: 700;
  color: var(--muted);
}

.product-img.placeholder::before {
  content: "ÖL";
}

.product-info {
  flex: 1;
  min-width: 0;
}

.product-info strong {
  display: block;
  font-weight: 700;
  font-size: var(--size);
}

.product-info span {
  display: block;
  font-size: var(--size-sm);
  color: var(--muted);
}

.product-item.selected .product-info span {
  color: #c0c0c0;
}

.product-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
}

.link-out {
  font-size: var(--size-sm);
  font-weight: 700;
  text-decoration: none;
  color: var(--title);
  padding: 0.1rem 0.25rem;
}

.delete-product-btn {
  margin: 0;
  padding: 0.1rem 0.35rem;
  min-height: 1.35rem;
  font-size: var(--size-sm);
}

.vote-list .vote-btn {
  flex-shrink: 0;
  min-width: 4.5rem;
}

/* —— Quantity —— */

.qty-row {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.qty-row input {
  flex: 1;
  text-align: center;
  margin-bottom: 0;
  font-weight: 700;
}

.qty-row button {
  width: 2.25rem;
  min-height: 2rem;
  margin-bottom: 0;
  padding: 0;
  font-weight: 700;
}

/* —— Summary tables —— */

.order-summary {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--shadow);
  background: var(--window);
  font-size: var(--size-sm);
}

.order-summary li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0.35rem;
  border-bottom: 1px solid var(--face);
}

.order-summary li:last-child {
  border-bottom: none;
}

/* —— Members —— */

.member-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0;
}

.chip {
  font-size: var(--size-sm);
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--shadow);
  background: var(--window);
}

.chip-current {
  background: var(--select-bg);
  color: var(--select-fg);
  border-color: var(--dark);
  font-weight: 700;
}

/* —— Order history —— */

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history-round {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--shadow);
}

.history-round:last-child {
  border-bottom: none;
}

.history-round-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.2rem;
  font-size: var(--size-sm);
}

.history-date {
  color: var(--muted);
  font-weight: 400;
}

.history-beer {
  margin: 0 0 0.15rem;
  font-size: var(--size-sm);
}

.admin-close-hint,
.admin-action-hint {
  margin: 0 0 0.35rem;
}

.admin-actions .admin-action-hint {
  margin-bottom: 0.35rem;
}

.admin-actions .btn-row {
  margin-bottom: 0;
}

.link-row input[type="tel"] {
  flex: 1;
  margin-bottom: 0;
}

.history-lines {
  margin-top: 0.25rem;
}

/* —— Alerts & status —— */

.status-banner {
  margin-bottom: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 2px solid;
  border-color: var(--light) var(--dark) var(--dark) var(--light);
  background: var(--window);
  color: var(--error);
  font-size: var(--size-sm);
  font-weight: 700;
}

.error,
#create-error,
#join-error {
  color: var(--error);
  font-size: var(--size-sm);
  font-weight: 700;
  margin: 0.35rem 0 0;
}

.success {
  color: var(--ok);
  font-size: var(--size-sm);
  margin: 0 0 0.5rem;
}

button.is-busy {
  color: var(--shadow);
  cursor: wait;
}

.alert {
  margin-bottom: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--shadow);
  background: var(--window);
  font-size: var(--size-sm);
}

.tie-products {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.35rem;
}

.tie-products button {
  width: 100%;
}

.admin-actions {
  margin-bottom: 0.35rem;
}

.manual-fallback {
  margin-bottom: 0.5rem;
  font-size: var(--size-sm);
}

.manual-fallback summary {
  cursor: pointer;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

code {
  font-family: "Courier New", Courier, monospace;
  font-size: 0.95em;
  background: var(--window);
  padding: 0 0.15rem;
  border: 1px solid var(--shadow);
}

/* Phones: larger type and tap targets (desktop sizes unchanged) */
@media (max-width: 640px) {
  :root {
    --size: 16px;
    --size-sm: 14px;
    --size-lg: 18px;
  }

  .wrap {
    padding: 1rem 1rem 2.75rem;
  }

  .page-header h1 {
    font-size: 2.25rem;
  }

  .win-checkbox,
  .win-radio {
    width: 18px;
    height: 18px;
  }

  .win-checkbox:checked,
  .win-radio:checked {
    background-size: 12px 12px;
  }

  button,
  .button {
    min-height: 2.25rem;
    padding: 0.35rem 0.75rem;
  }

  input[type="text"],
  input[type="url"],
  input[type="number"],
  textarea {
    padding: 0.4rem 0.35rem;
  }

  .product-img {
    width: 48px;
    height: 48px;
  }

  .qty-row button {
    width: 2.75rem;
    min-height: 2.5rem;
  }

  .vote-list .vote-btn {
    min-width: 5.5rem;
  }

  .delete-product-btn {
    min-height: 2rem;
    padding: 0.25rem 0.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
