:root {
  --bg: #f3f7fb;
  --surface: #ffffff;
  --text: #132742;
  --muted: #5e7088;
  --line: #d7e3f2;
  --accent: #0866e8;
  --danger: #9f3143;
  --app-shell-max: 1080px;
  --rail-divider-color: #dce6f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Noto Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top right, #dce9ff 0%, var(--bg) 54%);
}

.hero {
  padding-block: 2rem 1rem;
}

.crumb {
  margin: 0;
}

.crumb a {
  color: #2a67be;
  text-decoration: none;
}

.crumb a:hover,
.crumb a:focus-visible {
  text-decoration: underline;
}

.hero h1 {
  margin: 0.45rem 0 0;
}

.hero p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.layout {
  margin: 1rem auto 1.25rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 1000px) {
  .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 1rem;
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.form-grid {
  display: grid;
  gap: 0.45rem;
}

label {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  color: var(--muted);
}

input,
select,
textarea,
button {
  width: 100%;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #bfd2ea;
  padding: 0.62rem 0.75rem;
  font-size: 0.98rem;
  color: var(--text);
  background: #fff;
}

textarea {
  min-height: 128px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #cde0ff;
  border-color: var(--accent);
}

button {
  border: none;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.97);
}

button.secondary {
  background: #2d5ea8;
}

button.ghost {
  background: #f4f8ff;
  color: #2a4d7f;
  border: 1px solid #d0def2;
}

.input-error {
  min-height: 1.1rem;
  margin: 0;
  color: var(--danger);
  font-size: 0.87rem;
}

.result-label {
  margin: 0;
  color: var(--muted);
}

.result-primary[hidden] {
  display: none;
}

.result-value {
  margin: 0.5rem 0 0;
  font-size: clamp(1.75rem, 4.5vw, 2.55rem);
  font-weight: 700;
}

.result-detail,
.result-note {
  margin: 0.55rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.result-actions {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
}

.result-feedback {
  min-height: 1.1rem;
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.result-disclosure {
  margin-top: 0.9rem;
  border: 1px solid #d9e6f8;
  border-radius: 10px;
  background: #f8fbff;
}

.result-disclosure summary {
  cursor: pointer;
  padding: 0.75rem 0.8rem;
  font-weight: 600;
  color: #1f426f;
}

.result-disclosure[open] summary {
  border-bottom: 1px solid #d9e6f8;
}

.formula-block {
  padding: 0.75rem 0.8rem 0.8rem;
}

.formula-title {
  margin: 0;
  font-weight: 600;
}

.formula-line {
  margin: 0.35rem 0 0;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  overflow-wrap: anywhere;
}

.precision-controls {
  padding: 0.75rem 0.8rem 0.8rem;
}

.precision-controls .inline-controls {
  max-width: none;
}

.favorites-strip {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid #e1ebf8;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel-head button,
.history-toolbar button {
  width: auto;
}

.panel-head h3 {
  margin: 0;
}

.chip-row {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-button {
  width: auto;
  min-height: 38px;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid #c8d9f1;
  background: #f5f9ff;
  color: #274a79;
  font-weight: 600;
}

.favorites-overflow {
  margin-top: 0.8rem;
}

.all-panel {
  padding: 0.75rem 0.8rem 0.8rem;
}

.note-panel ul {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.55;
  color: var(--muted);
}

.note-wrap {
  margin: 0 auto 2rem;
}

.note-wrap .note-panel {
  width: 100%;
}

.advanced-wrap {
  margin: 0 auto 2rem;
}

.advanced-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.advanced-panel-body {
  margin-top: 0.8rem;
}

.advanced-section {
  margin-top: 0.25rem;
  border-top: 1px solid #e1ebf8;
  padding-top: 1rem;
}

.advanced-section-title {
  margin: 0 0 0.5rem;
  color: #1f426f;
}

.batch-example {
  margin: 0.3rem 0 0.55rem;
  font-size: 0.9rem;
}

.batch-input::placeholder {
  color: #9aa9bc;
}

.inline-controls {
  display: grid;
  gap: 0.45rem;
  max-width: 320px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.checkbox-row input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  margin: 0;
}

.inline-buttons {
  margin-top: 0.65rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.muted {
  color: var(--muted);
}

.all-rows {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.55rem;
}

.all-group-title {
  margin: 0.6rem 0 0.35rem;
  color: #2a4f7f;
  font-size: 0.92rem;
}

.all-row {
  border: 1px solid #d8e4f5;
  border-radius: 10px;
  padding: 0.55rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
}

.all-row strong {
  font-size: 1rem;
}

.all-row .meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.all-row.target {
  border-color: #98befa;
  background: #f1f7ff;
}

.all-row.input-unit {
  border-style: dashed;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.74rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #c8d9f1;
  color: #305079;
  background: #f5f9ff;
}

.table-scroll {
  overflow-x: auto;
}

.batch-table {
  margin-top: 0.65rem;
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.batch-table th,
.batch-table td {
  border: 1px solid #d7e2f0;
  padding: 0.45rem 0.5rem;
  text-align: left;
  font-size: 0.9rem;
  vertical-align: top;
}

.batch-table th {
  background: #f2f7ff;
}

.batch-table td:last-child {
  min-width: 180px;
}

.status-ok {
  color: #2a6c44;
}

.status-error {
  color: #6a4a15;
}

.item-list {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.item-list li {
  border: 1px solid #d6e3f5;
  border-radius: 10px;
  padding: 0.55rem;
}

.item-title {
  margin: 0;
  font-weight: 600;
}

.item-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.item-actions {
  margin-top: 0.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.45rem;
}

.history-wrap {
  margin: 0 auto 2rem;
}

.history-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.history-toolbar {
  margin-top: 0.8rem;
  display: flex;
  justify-content: flex-end;
}

.combobox {
  position: relative;
}

.combobox.is-open input {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px #cde0ff;
}

.combo-list {
  margin: 0.2rem 0 0;
  padding: 0.25rem;
  list-style: none;
  border: 1px solid #c8d9f1;
  border-radius: 10px;
  background: #fff;
  max-height: 260px;
  overflow-y: auto;
  position: absolute;
  width: 100%;
  z-index: 30;
  box-shadow: 0 10px 22px rgba(14, 36, 71, 0.11);
}

.combo-item {
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}

.combo-item:hover,
.combo-item.active {
  background: #edf5ff;
}

.combo-empty {
  padding: 0.45rem 0.5rem;
  color: var(--muted);
}

@media (max-width: 720px) {
  .all-row {
    grid-template-columns: 1fr;
  }

  .combo-list {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: max(1rem, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(50vh, 22rem);
    border-radius: 16px;
    padding: 0.4rem;
    box-shadow: 0 18px 36px rgba(14, 36, 71, 0.18);
  }
}

.tool-footer {
  margin-top: 2rem;
  padding-bottom: 1rem;
}

.tool-footer__inner {
  padding-bottom: 1rem;
  text-align: left;
}

.tool-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-bottom: 0.8rem;
}

.tool-footer__nav a {
  text-decoration: none;
  color: inherit;
}

.tool-footer__nav a:hover,
.tool-footer__nav a:focus-visible {
  text-decoration: underline;
}

.tool-footer__meta {
  margin: 0;
  color: #53637a;
  line-height: 1.55;
  font-size: 0.94rem;
}
