.study-dialog {
  --study-text: #4f4437;
  --study-rule: #d9c9ae;
  max-width: min(440px, calc(100vw - 28px));
  width: 100%;
  max-height: calc(100svh - 36px);
  margin: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(20px, 4vw, 32px);
  background: #fffaf0;
  border: 1.5px solid #95816a;
  border-radius: 20px 17px 21px 16px;
  box-shadow: 0 4px 0 #68543d3d, 0 14px 42px #493b2b30;
  color: var(--study-text);
  font: 400 1rem/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.study-dialog::backdrop { background: rgba(69, 55, 39, .34); }
.study-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.study-top h2 { margin: 0; font: 400 2.2rem/1.1 var(--hand); }
.study-close {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0 0 2px;
  border: 1px solid #cabb9e;
  border-radius: 50%;
  background: #fffdf6;
  color: #5c4d3f;
  font: 400 1.55rem/1 var(--hand);
}
.study-rhythm { margin: 7px 0 25px; color: #665b4e; font-size: .91rem; }
.study-rhythm span { margin: 0 3px; }
.study-label { display: block; margin: 0 0 8px; padding: 0; font: 400 1.25rem/1.2 var(--hand); }
.study-input {
  display: block;
  width: 100%;
  height: 45px;
  color: var(--study-text);
  background: #fffdf8;
  border: 1px solid #ad987d;
  border-radius: 9px 11px 9px 10px;
  padding: 0 12px;
  font: inherit;
}
.study-input:focus-visible, .study-custom:focus-within { outline: 2px solid #7a8a68; outline-offset: 2px; }
.study-input::placeholder { color: #827564; }
.study-color-field { border: 0; padding: 0; margin: 23px 0 25px; min-width: 0; }
.study-swatches { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; }
.study-swatch, .study-custom {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 39px;
  height: 40px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
}
.study-swatch::before, .study-custom::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 1px solid #453e3444;
  border-radius: 46% 48% 47% 49%;
  background: var(--swatch);
}
.study-swatch[aria-pressed=true]::before, .study-custom.chosen::before {
  outline: 2px solid #564636; outline-offset: 3px;
}
.study-custom { margin-left: 3px; }
.study-custom::before { background: conic-gradient(#c58970, #cfb071, #819a75, #74a2ad, #ac90b2, #c58970); }
.study-custom.chosen::before { background: var(--custom-color); }
.study-custom::after { position: absolute; content: "+"; color: #322d25; text-shadow: 0 0 2px #fffaf0; font: 700 1rem/1 sans-serif; }
.study-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.study-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; flex-wrap: wrap; border-top: 1px dashed var(--study-rule); padding-top: 18px; }
.study-button { padding: 8px 18px; border-radius: 12px 14px 13px 11px; min-height: 42px; border: 1px solid #a28e72; font: 400 1.15rem/1.15 var(--hand); }
.study-secondary { background: #fffaf0; color: #5c4d3c; }
.study-primary { color: #31432e; background: #d9e6ce; border-color: #7e906e; box-shadow: 0 2px 0 #a6b393; }
.study-button:disabled { opacity: .52; box-shadow: none; }
.study-timeline { max-width: min(560px, calc(100vw - 28px)); }
.study-timeline[open] { display: flex; flex-direction: column; overflow: hidden; }
.study-history-list { overflow-y: auto; overscroll-behavior: contain; margin: 20px -3px 0; padding: 0 3px 5px; }
.study-date { margin: 0 0 9px; color: #685a4a; font: 400 1.12rem/1.3 var(--hand); }
.study-day + .study-day { margin-top: 20px; }
.study-log { list-style: none; margin: 0; padding: 0; }
.study-entry { position: relative; display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 9px; min-height: 42px; padding: 8px 0 8px 14px; border-top: 1px solid #ebe0cb; }
.study-entry::before { position: absolute; left: 1px; inset-block: 10px; width: 4px; content: ""; border-radius: 4px; background-color: var(--task-color); box-shadow: inset 0 0 0 1px #0001; }
.study-entry-name { font-weight: 520; font-size: .93rem; overflow-wrap: anywhere; }
.study-entry-time { color: #6b5e4e; font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.study-tag { font: 400 .98rem/1.2 var(--hand); color: #5a654d; background: #edf0e1; border-radius: 7px; padding: 2px 6px; text-align: center; }
.study-history-actions { margin-top: 17px; flex: none; }
.study-empty { margin: 5px 0 15px; color: #655a4b; font-size: .97rem; }
#study-task::before { content: ""; display: inline-block; width: .62em; height: .62em; margin-right: .4em; vertical-align: .04em; border-radius: 50%; background-color: var(--task-color); box-shadow: inset 0 0 0 1px #0002; }
@media (max-width: 420px) {
  .study-dialog { padding: 20px; }
  .study-entry { grid-template-columns: minmax(0,1fr) auto; row-gap: 2px; }
  .study-entry-time { grid-area: 2/1; }
  .study-tag { grid-area: 1/2/3; }
  .study-swatches { gap: 0; }
  .study-swatch, .study-custom { width: 35px; }
}
