.lk-dialog-open { overflow: hidden; }
.lk-dialog {
  --lk-ink: #252720;
  --lk-muted: #636359;
  --lk-line: #deded4;
  --lk-paper: #fffef9;
  --lk-accent: #fd843c;
  color: var(--lk-ink);
  background: var(--lk-paper);
  border: 1px solid #d8d8cd;
  border-radius: 26px;
  padding: 0;
  margin: auto;
  width: min(460px, calc(100% - 36px));
  max-width: none;
  max-height: min(90vh, 780px);
  max-height: min(90dvh, 780px);
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 25px 95px #171b1840;
  font: inherit;
  text-align: left;
}
.lk-dialog *, .lk-dialog *::before, .lk-dialog *::after { box-sizing: border-box; }
.lk-dialog::backdrop { background: rgba(28, 31, 25, .47); }
.lk-dialog [hidden] { display: none !important; }
.lk-form { display: flex; flex-direction: column; margin: 0; }
.lk-form-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 25px 26px 18px; gap: 12px; }
.lk-form-date { margin: 0 0 5px; color: var(--lk-muted); font-size: .87rem; line-height: 1.4; font-weight: 550; }
.lk-form-head h2 { margin: 0; color: var(--lk-ink); font-size: clamp(1.55rem, 5vw, 1.9rem); font-weight: 700; line-height: 1.12; letter-spacing: -.045em; }
.lk-form button { cursor: pointer; -webkit-tap-highlight-color: transparent; font: inherit; }
.lk-close {
  background: #f0f0e8; color: var(--lk-ink); border: 0; padding: 0;
  width: 44px; height: 44px; border-radius: 50%; display: grid; flex-shrink: 0; place-items: center;
}
.lk-close svg { stroke-linecap: round; }
.lk-form-body { display: grid; gap: 17px; padding: 0 26px; }
.lk-field { display: grid; align-content: start; gap: 7px; min-width: 0; }
.lk-field label { font-size: .92rem; line-height: 1.4; font-weight: 650; color: var(--lk-ink); }
.lk-field input, .lk-field select {
  appearance: none; -webkit-appearance: none; font: inherit; line-height: 1.3;
  font-size: max(1rem, 16px); font-weight: 500; width: 100%; min-width: 0; min-height: 48px;
  color: var(--lk-ink); background-color: white; border: 1px solid var(--lk-line);
  border-radius: 12px; padding: 11px 13px; margin: 0;
}
.lk-field input::placeholder { color: #75766c; font-weight: 400; }
.lk-field select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 16 16'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%23464a40' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.lk-dialog :focus-visible { outline: 2px solid #96602d; outline-offset: 2px; }
.lk-field input:focus, .lk-field select:focus { border-color: #936f45; }
.lk-unit-field { position: relative; }
.lk-unit-field input { padding-right: 47px; }
.lk-unit-field > span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  line-height: 1; pointer-events: none; font-size: .87rem; color: var(--lk-muted);
}
.lk-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.lk-segments { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; border-radius: 14px; padding: 3px; background: #f0f1e9; }
.lk-segments button {
  background: transparent; font-size: .92rem; line-height: 1.25;
  color: #515349; font-weight: 600; min-height: 44px; border: 1px solid transparent; border-radius: 11px; padding: 6px;
}
.lk-segments button[aria-pressed="true"] { background: white; color: var(--lk-ink); border-color: #dedfd3; box-shadow: 0 1px 2px #1b201219; }
.lk-gram-panel { display: grid; gap: 12px; }
.lk-direct { display: grid; gap: 16px; }
.lk-macros { min-width: 0; margin: 0; padding: 0; border: 0; }
.lk-macros legend { padding: 0 0 9px; color: var(--lk-ink); font-size: .93rem; font-weight: 650; }
.lk-macros legend small { color: var(--lk-muted); font-size: .85rem; font-weight: 450; }
.lk-macro-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.lk-macro-fields label { font-size: .875rem; }
.lk-macro-fields .lk-unit-field input { padding-right: 25px; }
.lk-macro-result { margin-top: -4px; color: var(--lk-muted); font-size: .86rem; line-height: 1.5; font-variant-numeric: tabular-nums; }
.lk-field textarea {
  min-height: 64px; width: 100%; resize: vertical; color: var(--lk-ink); font: inherit; font-size: max(1rem, 16px);
  line-height: 1.4; background: #fff; border: 1px solid var(--lk-line); border-radius: 12px; padding: 10px 13px;
}
@media (max-width: 325px) { .lk-macro-fields { grid-template-columns: 1fr; } }
.lk-total { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .94rem; background: #f9eddc; border-radius: 12px; padding: 14px; }
.lk-total output { letter-spacing: -.025em; font-size: 1.125rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.lk-hint, .lk-source, .lk-note { margin: 0; font-size: .875rem; line-height: 1.48; color: var(--lk-muted); }
.lk-source a { color: #6b491e; text-underline-offset: 2px; }
.lk-form-footer { padding: 19px 26px 24px; }
.lk-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.lk-actions button {
  min-height: 48px; border: 0; border-radius: 13px; font-weight: 700; font-size: 1rem;
  padding: 10px 14px; line-height: 1.3;
}
.lk-actions button:disabled { opacity: .5; cursor: default; }
.lk-save, .lk-delete { flex: 1 1 auto; background: var(--lk-accent); color: #211e15; }
.lk-remove, .lk-cancel { flex: 0 1 auto; background: #f0f0e8; color: #4d4e45; }
.lk-confirm p { margin: 0 0 10px; font-weight: 650; font-size: 1rem; }
.lk-actions .lk-delete { background: #a13323; color: white; }
.lk-error { margin: 0 0 12px; font-size: .91rem; line-height: 1.4; color: #922f21; }
@media (max-width: 540px) {
  .lk-dialog {
    position: fixed; inset: auto 0 0; margin: 0 auto; width: 100%; border-radius: 24px 24px 0 0; border-bottom: none;
    max-height: calc(100vh - 18px); max-height: calc(100dvh - max(18px, env(safe-area-inset-top)));
  }
  .lk-form-head { padding: 22px 20px 17px; }
  .lk-form-body { padding: 0 20px; }
  .lk-form-footer { padding: 18px 20px max(20px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: no-preference) {
  .lk-dialog[open] { animation: lk-enter 150ms ease-out; }
  @keyframes lk-enter { from { opacity: .5; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
