﻿:root {
  --control-height: 42px;
  --panel-width: 380px;
}

body {
  font-family: "Segoe UI", sans-serif;
  font-size: 15px;
  background: #111;
  color: #eee;
}

.disclaimer {
  width: min(920px, calc(100% - 24px));
  max-width: 920px;
  box-sizing: border-box;
  margin: 20px auto 0;
  padding: 12px 14px;
  background: #3b2d00;
  border: 1px solid #7a5d00;
  border-radius: 8px;
  color: #ffe7a1;
}

.container {
  display: flex;
  width: min(920px, calc(100% - 24px));
  gap: 40px;
  margin: 40px auto;
  align-items: flex-start;
}

.panel {
  padding: 30px;
  background: #1c1c1c;
  border-radius: 12px;
}

.panel h2 {
  margin: 0 0 12px;
}

.left {
  width: var(--panel-width);
}

.right {
  width: var(--panel-width);
  flex: 0 0 var(--panel-width);
  padding: 30px;
}

#recommendation {
  margin-bottom: 4px;
  text-align: left;
}

.result-alert {
  position: sticky;
  top: 0;
  z-index: 5;
}

.field {
  margin-bottom: 15px;
}

.field > label,
.panel > label {
  display: block;
  margin-top: 0;
  margin-bottom: 6px;
}

.top-input-row {
  display: grid;
  grid-template-columns: 1fr 102px 110px;
  gap: 10px;
  align-items: start;
}

.inline {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
}

.shape-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.dimension-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shape-option {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--control-height);
  padding: 0 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a2a;
  margin: 0;
  cursor: pointer;
}

.shape-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.shape-label {
  flex: 1;
  user-select: none;
}

.rect-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.rect-side-option {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--control-height);
  padding: 0 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a2a;
  cursor: pointer;
}

.rect-side-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.rect-side-text {
  flex: 1;
  user-select: none;
}

.rect-side-option input:checked + .switch {
  background: #007acc;
}

.rect-side-option input:checked + .switch::after {
  transform: translateX(20px);
}

.rect-side-option input:checked + .switch + .rect-side-text {
  color: #fff;
}

input, select, button {
  width: 100%;
  height: var(--control-height);
  padding: 10px;
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #444;
  border-radius: 6px;
  box-sizing: border-box;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
.shape-option:focus-within,
.mode-option:focus-within,
.rect-side-option:focus-within,
.info-tip:focus-visible {
  outline: 2px solid #4db1ff;
  outline-offset: 2px;
}

input.input-error {
  border-color: #ff6b6b;
  background: #3a2020;
  box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
}

input::placeholder {
  color: rgba(238, 238, 238, 0.45);
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field input[type="range"] {
  padding: 0;
  height: 28px;
}

.disabled-field label {
  opacity: 0.6;
}

.disabled-field input[type="range"] {
  opacity: 0.45;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  height: var(--control-height);
  padding: 0 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a2a;
  cursor: pointer;
}

.mode-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-label {
  flex: 1;
  user-select: none;
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border-radius: 50%;
  background: #3b4b58;
  color: #d9e6f2;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
}

.info-tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 280px;
  padding: 8px 10px;
  border: 1px solid #4a5f70;
  border-radius: 6px;
  background: #1b2730;
  color: #d7e9f7;
  font-size: 12px;
  font-weight: 400;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 20;
}

.info-tip:hover::after {
  opacity: 1;
}

.info-tip:focus-visible::after,
.info-tip:active::after {
  opacity: 1;
}

.info-tip-tight::after {
  min-width: 0;
  max-width: none;
  white-space: nowrap;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #555;
  border-radius: 999px;
  flex: 0 0 auto;
  transition: background 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.shape-option input:checked + .switch,
.mode-option input:checked + .switch,
.rect-side-option input:checked + .switch {
  background: #007acc;
}

.shape-option input:checked + .switch::after,
.mode-option input:checked + .switch::after,
.rect-side-option input:checked + .switch::after {
  transform: translateX(20px);
}

.shape-option input:checked + .switch + .shape-label,
.mode-option input:checked + .switch + .mode-label,
.rect-side-option input:checked + .switch + .rect-side-text {
  color: #fff;
}

.mode-row input[type="number"]:disabled,
.mode-row input[type="number"][readonly] {
  opacity: 0.6;
}

button {
  background: #007acc;
  cursor: pointer;
  margin-bottom: 15px;
}

button:hover {
  background: #0094ff;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

.shortcut-hint {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid #324558;
  border-radius: 8px;
  background: linear-gradient(180deg, #1d2630 0%, #1a222b 100%);
  color: #9fb3c5;
  font-size: 11px;
  line-height: 1.2;
}

.shortcut-title {
  color: #b8cad9;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.shortcut-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(53, 73, 92, 0.35);
  color: #c9d9e7;
}

.shortcut-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #536a80;
  border-radius: 5px;
  background: #23303d;
  color: #e2edf8;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
}

button.secondary {
  background: #3a4754;
}

button.secondary:hover {
  background: #4b5f73;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 4px;
}

th, td {
  padding: 5px 6px;
  text-align: left;
  line-height: 1.15;
}

#resultTable th {
  font-size: 16px;
  font-weight: 400;
  font-family: inherit;
}

td {
  font-size: 13px;
}

tr:nth-child(even) {
  background: #222;
}

#resultTable tbody tr {
  cursor: pointer;
}

#resultTable tbody tr:hover {
  background: #2b323a;
}

#resultTable tbody tr.green {
  background: #123d12;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.status-badge.recommended {
  color: #d9ffe1;
  background: #1f6b2a;
}

.field-error {
  margin-top: 5px;
  color: #ff9c9c;
  font-size: 12px;
}

.helper-text {
  margin-top: 6px;
  color: #b8ccdc;
  font-size: 12px;
  line-height: 1.3;
}

.inline-warning {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #6f5a19;
  border-radius: 6px;
  background: #332a12;
  color: #f1dfad;
  font-size: 12px;
  line-height: 1.3;
}


.recommend {
  font-size: 14px;
  margin-bottom: 4px;
  font-weight: bold;
  line-height: 1.2;
}

.recommend.error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #8a2a2a;
  border-left: 4px solid #d74747;
  border-radius: 8px;
  background: linear-gradient(90deg, #3a1515 0%, #2b1b1b 100%);
  color: #ffd0d0;
  font-weight: 600;
}

.recommend.error::before {
  content: "!";
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: #d74747;
  color: #2a0c0c;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.recommend.warning {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid #8c6f1a;
  border-left: 4px solid #d2a51a;
  border-radius: 8px;
  background: linear-gradient(90deg, #3a2e10 0%, #2c2616 100%);
  color: #ffe7a1;
  font-weight: 600;
}

.recommend.warning::before {
  content: "!";
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: #d2a51a;
  color: #1e1600;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.result-summary {
  margin: 8px 0 10px;
  padding: 12px;
  border: 1px solid #36506d;
  border-radius: 10px;
  background: linear-gradient(145deg, #1b2632 0%, #1b222a 100%);
}

.result-summary-dimension {
  margin-top: 4px;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
}

.result-chips {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-chip {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #3f556d;
  background: #223241;
  color: #cfe2f3;
  font-size: 12px;
  font-weight: 600;
}


.version-note {
  width: min(920px, calc(100% - 24px));
  margin: 14px auto 20px;
  color: #a6b8c7;
  font-size: 12px;
  text-align: right;
}

@media (max-width: 980px) {
  .container {
    width: min(560px, calc(100% - 24px));
    flex-direction: column;
    gap: 16px;
    margin-top: 18px;
  }

  .left,
  .right {
    width: 100%;
    flex: 1 1 auto;
  }

  .top-input-row,
  .mode-row,
  .dimension-row,
  .rect-row {
    grid-template-columns: 1fr;
  }
}
