.calc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  min-width: 0;
}
.calc-panel {
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--surface-color);
}
.calc-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}
.calc-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
}
.calc-panel-title svg { width: 16px; height: 16px; color: var(--accent-color); }
.calc-query-wrap { padding: 14px; }
.calc-query {
  min-height: 112px;
  resize: vertical;
  line-height: 1.55;
  font-size: 15px;
}
.calc-action-row,
.graph-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.calc-status {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 12px;
  font-family: var(--font-mono);
}
.calc-result-list,
.calc-history-list {
  display: flex;
  flex-direction: column;
}
.calc-result-empty,
.calc-history-empty {
  padding: 20px 14px;
  color: var(--text-tertiary);
  font-size: 13px;
}
.calc-result-row,
.calc-history-item {
  min-width: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
}
.calc-result-row:last-child,
.calc-history-item:last-child { border-bottom: 0; }
.calc-result-label {
  margin-bottom: 5px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.calc-result-value,
.calc-history-expression,
.calc-history-result {
  overflow-wrap: anywhere;
  color: var(--text-main);
  font-family: var(--font-mono);
  line-height: 1.45;
}
.calc-result-value { font-size: 15px; }
.calc-history-expression { font-size: 12px; }
.calc-history-result { margin-top: 4px; color: var(--text-secondary); font-size: 11px; }
.calc-history-item {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.calc-history-item:hover { background: var(--hover-bg); }
.calc-keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 12px;
}
.calc-key {
  min-height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--surface-color);
  color: var(--text-main);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 13px;
}
.calc-key:hover { border-color: var(--text-tertiary); background: var(--hover-bg); }
.calc-key.is-accent { color: var(--accent-color); }
.calc-key.is-wide { grid-column: span 2; }
.graph-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}
.graph-sidebar { min-width: 0; }
.graph-functions { display: flex; flex-direction: column; }
.graph-function {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
}
.graph-function-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.graph-function-input { min-width: 0; }
.graph-function input { min-width: 0; }
.graph-function-error,
.graph-status {
  min-height: 16px;
  color: var(--error-color);
  font-size: 11px;
  line-height: 1.35;
}
.graph-function-error {
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.graph-status {
  padding: 0 12px 12px;
  color: var(--text-tertiary);
}
.graph-status.has-errors { color: var(--error-color); }
.graph-function .btn-icon { width: 32px; height: 32px; }
.graph-action-row .btn-icon { width: 32px; height: 32px; }
.graph-nav-pad {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  gap: 6px;
  justify-content: center;
  padding: 0 12px 12px;
}
.graph-nav-pad .btn-icon {
  width: 36px;
  height: 36px;
}
.graph-board-wrap {
  min-width: 0;
  height: min(70vh, 720px);
  min-height: 460px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface-color);
}
.graph-board {
  width: 100%;
  height: 100%;
  touch-action: none;
}
.graph-board:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: -3px;
}
.graph-board.jxgbox {
  border: 0;
  background: var(--surface-color);
}
.graph-loading {
  display: grid;
  min-height: 460px;
  place-items: center;
  color: var(--text-tertiary);
}
.graph-loading[hidden] {
  display: none;
}

@media (max-width: 900px) {
  .calc-layout,
  .graph-layout { grid-template-columns: 1fr; }
  .calc-layout .calc-panel:last-child { order: -1; }
  .graph-board-wrap { min-height: 420px; height: 58vh; }
}

@media (max-width: 520px) {
  .calc-query-wrap { padding: 10px; }
  .calc-query { min-height: 92px; }
  .graph-function { grid-template-columns: 16px minmax(0, 1fr) 44px; }
  .graph-function .btn-icon,
  .graph-action-row .btn-icon,
  .graph-nav-pad .btn-icon {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }
  .graph-action-row .btn-sm { min-height: 44px; }
  .graph-nav-pad { grid-template-columns: repeat(3, 44px); }
  .graph-board-wrap { min-height: 360px; height: 56vh; }
}
