/* One fixed-height reader row; opening a clock tool never resizes the ink workbench. */
.has-note-editor .note-editor-material.has-study-reader-timer {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.study-reader-timer {
  position: relative;
  z-index: 220;
  flex: 0 0 auto;
  min-width: 0;
  color: #173b30;
  background: #f5faf7;
  border-bottom: 1px solid #dce9e1;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
}

.study-reader-timer *, .study-reader-timer *::before, .study-reader-timer *::after { box-sizing: border-box; }
.study-reader-timer [hidden] { display: none !important; }
.study-reader-timer .study-reader-timer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 44px;
  min-width: 0;
  padding: 3px 14px;
}

.study-reader-timer button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: auto;
  min-width: 0;
  min-height: 36px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #cedfd5;
  border-radius: 10px;
  background: #fff;
  color: #205341;
  font: inherit;
  font-weight: 650;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: none;
}

.study-reader-timer button:disabled { opacity: .45; cursor: default; }
.study-reader-timer button:focus-visible, .study-reader-timer input:focus-visible { outline: 2px solid #087b62; outline-offset: 2px; }
.study-reader-timer button:hover:not(:disabled) { background: #edf7f0; }
.study-reader-timer .study-reader-timer-toggle { min-height: 34px; padding: 5px 10px; border-radius: 18px; background: #e8f4ec; border-color: #c9e0d3; font-size: 12px; }
.study-reader-timer .study-reader-timer-toggle > span:first-child { font-size: 20px; line-height: 1; }
.study-reader-timer-short-title { display: none; }
.study-reader-timer-summary { overflow: hidden; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; color: #527365; }

.study-reader-timer .study-reader-timer-flyout {
  position: absolute;
  z-index: 1;
  top: calc(100% + 5px);
  right: 10px;
  width: min(390px, calc(100% - 20px));
  max-height: min(500px, 64vh);
  max-height: min(500px, 64dvh);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid #cfe0d5;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 34px #123d292b;
  scrollbar-gutter: stable;
}

.study-reader-timer-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 5px; }
.study-reader-timer-heading > strong { font-size: 14px; }
.study-reader-timer .study-reader-timer-heading > button { min-height: 32px; width: 32px; padding: 0; border: 0; font-size: 23px; }
.study-reader-timer-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin: 0 12px; padding: 3px; border-radius: 11px; background: #f0f5f2; }
.study-reader-timer .study-reader-timer-tabs > button { min-height: 36px; padding: 5px 2px; border: 0; border-radius: 8px; background: transparent; font-size: 12px; }
.study-reader-timer .study-reader-timer-tabs > button[aria-selected="true"] { color: #086044; background: #fff; box-shadow: 0 1px 4px #173b301a; }
.study-reader-timer-content { padding: 14px 16px 8px; text-align: center; }
.study-reader-timer-content > [role="tabpanel"] { display: grid; justify-items: center; gap: 9px; margin: 0; }
.study-reader-timer-caption { display: block; margin: 0; color: #638073; font-size: 12px; }
.study-reader-timer-digits { display: block; color: #143e2f; font-size: clamp(29px, 5vw, 38px); font-weight: 700; line-height: 1.15; letter-spacing: .025em; font-variant-numeric: tabular-nums; }
.study-reader-timer .study-reader-timer-detail { min-height: 18px; margin: 0; color: #567163; font-size: 12px; }
.study-reader-timer-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; }
.study-reader-timer .study-reader-timer-buttons > button { min-width: 78px; min-height: 40px; }
.study-reader-timer button.is-primary { background: #087b62; border-color: #087b62; color: #fff; }
.study-reader-timer button.is-primary:hover:not(:disabled) { background: #086c56; }
.study-reader-timer-inputs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 9px; }
.study-reader-timer-inputs > label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.study-reader-timer-inputs > small { color: #6c8177; font-size: 11px; }
.study-reader-timer input { min-width: 0; height: 38px; margin: 0; padding: 6px; border: 1px solid #cbded1; border-radius: 8px; color: #173b30; background: #fff; font: inherit; font-size: 16px; font-variant-numeric: tabular-nums; }
.study-reader-timer input[type="number"] { width: 67px; text-align: center; }
.study-reader-timer input[name="seconds"] { width: 53px; }
.study-reader-timer input:disabled { opacity: .7; background: #f4f7f5; }
.study-reader-timer input.study-reader-timer-alarm-input { width: 160px; min-height: 44px; height: 44px; font-size: 23px; text-align: center; }
.study-reader-timer .study-reader-timer-hint { margin: 0; padding: 6px 16px 12px; color: #73857b; font-size: 11px; line-height: 1.5; text-align: left; }
.study-reader-timer .study-reader-timer-error { margin: 2px 14px 6px; padding: 8px; border-radius: 8px; color: #a34232; background: #fff3ef; font-size: 12px; }
.study-reader-timer-notice { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; color: #185638; background: #eaf7dc; border-bottom: 1px solid #d5e8c8; }
.study-reader-timer-notice > span { min-width: 0; font-size: 12px; }
.study-reader-timer .study-reader-timer-notice > button { flex: 0 0 auto; min-height: 36px; padding: 5px 9px; }

@media (max-width: 440px) {
  .study-reader-timer .study-reader-timer-bar { padding-inline: 8px; }
  .study-reader-timer-title { display: none; }
  .study-reader-timer-short-title { display: inline; }
  .study-reader-timer-summary { font-size: 11px; }
  .study-reader-timer .study-reader-timer-flyout { right: 6px; width: calc(100% - 12px); }
}

@media (max-height: 550px) and (orientation: landscape) {
  .study-reader-timer .study-reader-timer-flyout { max-height: 60vh; max-height: 60dvh; }
  .study-reader-timer-content { padding-block: 8px; }
  .study-reader-timer-content > [role="tabpanel"] { gap: 5px; }
}

/* A phone in landscape must still leave room for ink. Keep all page actions
   reachable in one horizontally scrollable row; only the explanatory hint hides. */
@media (max-height: 450px) and (orientation: landscape) {
  .study-reader-timer .study-reader-timer-bar { height: 38px; }
  .has-note-editor .note-editor-material.has-study-reader-timer .note-pagebar {
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 5px;
    min-height: 46px;
    padding: 4px 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
  }
  .has-note-editor .note-editor-material.has-study-reader-timer .note-pagebar > :not(small) { flex: 0 0 auto; }
  .has-note-editor .note-editor-material.has-study-reader-timer .note-pagebar > small { display: none; }
  .has-note-editor .note-editor-material.has-study-reader-timer .note-pagebar .study-touch-mode,
  .has-note-editor .note-editor-material.has-study-reader-timer .note-pagebar .study-reader-view-controls {
    width: auto;
    max-width: none;
    margin-inline: 0;
  }
  .has-note-editor .note-editor-material.has-study-reader-timer .hand-canvas-stage.is-material-page { padding: 6px; }
}
